-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
195 lines (186 loc) · 5.27 KB
/
Dockerfile
File metadata and controls
195 lines (186 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
ARG ALPINE_VERSION=3.23
ARG PHP_VERSION=8.4.16
ARG NGINX_VERSION=1.29.4
FROM alpine:${ALPINE_VERSION}
ARG ALPINE_VERSION
ARG PHP_VERSION
ARG NGINX_VERSION
LABEL \
org.opencontainers.image.title="PHP + NGINX (compiled from source)" \
org.opencontainers.image.description="Image built from Alpine with PHP and NGINX compiled from source using only permissive licenses (MIT/BSD/Apache)" \
org.opencontainers.image.source="https://github.com/fontebasso/docker-php-nginx" \
org.opencontainers.image.licenses="MIT" \
maintainer="Samuel Fontebasso <samuel.txd@gmail.com>" \
alpine="${ALPINE_VERSION}" \
php_version="${PHP_VERSION}" \
nginx_version="${NGINX_VERSION}"
ENV APP_DIR="/app"
RUN set -eux; \
ln -sf /bin/false /usr/bin/tar; \
apk update; \
apk add --no-cache \
ca-certificates \
curl \
git \
libarchive-tools \
libedit \
libevent \
libzip \
oniguruma \
openssl \
runit \
sqlite-libs \
tzdata \
zlib;
RUN set -eux; \
apk add --no-cache --virtual .build-nginx-deps \
build-base \
openssl-dev \
pcre2-dev \
zlib-dev; \
curl -fsSL https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -o /tmp/nginx.tar.gz; \
curl -fsSL https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.38.tar.gz -o /tmp/headers-more.tar.gz; \
mkdir -p /tmp/nginx /tmp/headers-more-nginx-module-0.38; \
bsdtar -xf /tmp/nginx.tar.gz -C /tmp; \
bsdtar -xf /tmp/headers-more.tar.gz -C /tmp; \
cd /tmp/nginx-${NGINX_VERSION}; \
./configure \
--add-module=/tmp/headers-more-nginx-module-0.38 \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--prefix=/opt/nginx \
--with-cc-opt='-O2 -fPIC -fstack-protector-strong' \
--with-ld-opt='-Wl,-z,relro,-z,now' \
--with-http_gzip_static_module \
--with-pcre \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-threads; \
make -j$(nproc); \
make install; \
ln -s /opt/nginx/sbin/nginx /usr/sbin/nginx; \
apk del .build-nginx-deps; \
rm -rf /tmp/nginx*
RUN set -eux; \
apk add --no-cache --virtual .build-php-deps \
abseil-cpp-dev \
autoconf \
bzip2-dev \
c-ares-dev \
curl-dev \
freetype-dev \
g++ \
gcc \
jpeg-dev \
libedit-dev \
libjpeg-turbo-dev \
libpng-dev \
libsodium-dev \
libwebp-dev \
libxml2-dev \
libxpm-dev \
libzip-dev \
linux-headers \
make \
oniguruma-dev \
openssl-dev \
pkgconf \
re2-dev \
sqlite-dev \
zlib-dev; \
curl -fsSL https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz -o /tmp/php.tar.gz; \
bsdtar -xf /tmp/php.tar.gz -C /tmp; \
cd /tmp/php-${PHP_VERSION}; \
export CFLAGS="-O2 -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2"; \
export LDFLAGS="-Wl,-z,relro,-z,now"; \
./configure \
--disable-cgi \
--disable-phpdbg \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-fpm \
--enable-gd \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-pdo \
--enable-shmop \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--prefix=/opt/php \
--with-bz2 \
--with-config-file-scan-dir=/opt/php/etc/php/conf.d \
--with-curl \
--with-freetype \
--with-jpeg \
--with-libedit \
--with-openssl \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png \
--with-sodium \
--with-webp \
--with-xpm \
--with-zip \
--with-zlib; \
make -j$(nproc); \
make install; \
cp sapi/fpm/php-fpm.conf /opt/php/etc/php-fpm.conf; \
cp sapi/fpm/www.conf /opt/php/etc/php-fpm.d/www.conf; \
cp php.ini-production /opt/php/lib/php.ini; \
ln -s /opt/php/sbin/php-fpm /usr/sbin/php-fpm; \
ln -s /opt/php/bin/php /usr/bin/php; \
ln -s /opt/php/bin/phpize /usr/bin/phpize; \
ln -s /opt/php/bin/php-config /usr/bin/php-config; \
mkdir -p /opt/php/etc/php/conf.d; \
printf "\n" | /opt/php/bin/pecl install grpc; \
echo "extension=grpc.so" > /opt/php/etc/php/conf.d/php-02-grpc.ini; \
rm -rf /opt/php/bin/pecl /opt/php/bin/pear /opt/php/bin/peardev /opt/php/bin/peclcmd.php /opt/php/bin/pearcmd.php /opt/php/bin/phar /opt/php/bin/phar.phar; \
find /opt/php -type f -name "peclcmd.php" -delete; \
find /opt/php -type f -name "pearcmd.php" -delete; \
find /opt/php -type d -name "pear" -exec rm -rf {} +; \
apk del .build-php-deps; \
rm -rf /tmp/php*
COPY ./src /
COPY ./custom_params.ini /opt/php/etc/php/conf.d/php-03-custom-params.ini
RUN set -eux; \
apk add --no-cache \
freetype \
libgomp \
libheif \
libjpeg-turbo \
libpng \
libraw \
librsvg \
libsodium \
libwebp \
libwmf \
libxml2 \
libxpm \
libzip \
oniguruma \
openjpeg \
libarchive-tools \
sqlite-libs; \
touch /env; \
chmod +x \
/sbin/runit-wrapper \
/sbin/runsvdir-start \
/etc/service/*/run; \
adduser -S www-data -G www-data; \
mkdir -p \
/run/nginx \
/var/log/nginx \
/opt/nginx/client_body_temp; \
chown -R www-data:www-data \
/app /env /etc/service /opt/nginx /var/log/nginx /opt/php /tmp /run/nginx
USER www-data
WORKDIR /app
EXPOSE 80
CMD ["/sbin/runit-wrapper"]