forked from A1mDev/hlstatsx-community-edition
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile.web
92 lines (75 loc) · 2.8 KB
/
Dockerfile.web
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
ARG IMAGE=php:8.1-fpm-alpine
FROM $IMAGE AS build
# Set permissions for 'www-data' user
# COPY --chown=www-data:www-data --chmod=640 /web /web
COPY ./src/web /web
RUN set -eux; \
chown -R www-data:www-data /web; \
find /web -type d -exec chmod 750 {} \; ; \
find /web -type f -exec chmod 640 {} \; ;
COPY ./src/heatmaps /heatmaps
RUN set -eux; \
chown -R www-data:www-data /heatmaps; \
find /heatmaps -type d -exec chmod 750 {} \; ; \
find /heatmaps -type f -exec chmod 640 {} \; ;
FROM $IMAGE AS dev
# Install nginx and supervisor for multi-process container
RUN apk add --no-cache ca-certificates nginx supervisor
# opcache
RUN docker-php-ext-install opcache
# mysqli (deprecated)
RUN set -eux; \
docker-php-ext-install mysqli
# gd
RUN set -eux; \
apk add --no-cache freetype libjpeg-turbo libpng; \
apk add --no-cache --virtual .deps freetype-dev libjpeg-turbo-dev libpng-dev; \
docker-php-ext-configure gd \
--with-freetype=/usr/include/ \
--with-jpeg=/usr/include/; \
docker-php-ext-install gd; \
apk del .deps
# PDO
RUN set -eux; \
docker-php-ext-install pdo pdo_mysql
# Sockets
# See: https://github.com/docker-library/php/issues/181#issuecomment-173365852
RUN set -eux; \
apk add --no-cache --virtual .deps linux-headers; \
docker-php-ext-install sockets; \
apk del .deps
# Xdebug: https://stackoverflow.com/questions/46825502/how-do-i-install-xdebug-on-dockers-official-php-fpm-alpine-image
# PHPIZE_DEPS: autoconf dpkg-dev dpkg file g++ gcc libc-dev make pkgconf re2c
RUN apk add --no-cache --virtual .build-dependencies $PHPIZE_DEPS \
&& pecl install xdebug-3.1.6 \
&& docker-php-ext-enable xdebug \
&& docker-php-source delete \
&& apk del .build-dependencies
RUN { \
echo "[xdebug]"; \
echo "zend_extension=xdebug"; \
echo "xdebug.mode=debug"; \
echo "xdebug.start_with_request=yes"; \
echo "xdebug.client_host=host.docker.internal"; \
echo "xdebug.client_port=9000"; \
} > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini;
RUN set -eux; \
echo; \
php -i; \
php -m
# Add configs
COPY ./config/web/. /
# Disable the built-in php-fpm configs, since we're using our own config
RUN set -eux; \
mv -v /usr/local/etc/php-fpm.d/docker.conf /usr/local/etc/php-fpm.d/docker.conf.disabled; \
mv -v /usr/local/etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf.disabled; \
mv -v /usr/local/etc/php-fpm.d/zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf.disabled;
WORKDIR /web
CMD ["/usr/bin/supervisord", "-c", "/supervisor.conf", "--pidfile", "/run/supervisord.pid"]
FROM dev AS prod
# Disable xdebug
RUN set -eux; \
rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
php -m;
COPY --from=build /web /web
COPY --from=build /heatmaps /heatmaps