-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
120 lines (89 loc) · 3.4 KB
/
Dockerfile
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
FROM node:14-alpine AS resources
WORKDIR /home/node/app
RUN chown node:node /home/node/app
USER node
COPY package*.json /home/node/app/
RUN npm ci
COPY --chown=node:node public /home/node/app/public
COPY resources/js /home/node/app/resources/js
COPY resources/sass /home/node/app/resources/sass
COPY webpack.mix.js /home/node/app/
RUN npm run production
########################################
FROM nginxinc/nginx-unprivileged:1.19-alpine AS nginx
USER root
RUN apk add --update --no-cache \
su-exec \
curl
COPY ./docker/nginx.conf /etc/nginx/nginx.conf
COPY ./docker/server.conf /etc/nginx/conf.d/default.conf
COPY ./docker/server-ssl.conf /etc/nginx/conf.d/default-ssl.conf.disabled
COPY --from=resources /home/node/app/public /var/www/html/public
HEALTHCHECK --start-period=15s --interval=30s --timeout=5s \
CMD curl -f http://localhost:8081/health || exit 1
EXPOSE 8080 8081 8443
COPY ./docker/nginx-entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
########################################
FROM php:8.0-fpm-alpine AS php-fpm
RUN apk add --update --no-cache --virtual build-dependencies \
autoconf gcc g++ libtool make \
&& apk add --update --no-cache \
libmcrypt-dev \
mysql-client \
libpng-dev \
unzip \
fcgi \
&& pecl install mcrypt-1.0.4 \
&& docker-php-ext-enable mcrypt \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install gd \
&& docker-php-ext-install opcache \
&& docker-php-ext-install pcntl \
&& apk del build-dependencies
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& echo 'log_errors_max_len = 0' >> $PHP_INI_DIR/conf.d/app.ini \
&& echo 'cgi.fix_pathinfo = 0' >> $PHP_INI_DIR/conf.d/app.ini \
&& echo 'date.timezone = UTC' >> $PHP_INI_DIR/conf.d/app.ini \
&& echo 'expose_php = 0' >> $PHP_INI_DIR/conf.d/app.ini
COPY ./docker/app-fpm.conf /usr/local/etc/php-fpm.d/zz-app-fpm.conf
WORKDIR /var/www/html
USER www-data
ARG COMPOSER_VERSION=2.1.3
RUN EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)"; \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"; \
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then \
>&2 echo 'ERROR: Invalid installer signature'; \
rm composer-setup.php; \
exit 1; \
fi; \
php composer-setup.php --quiet --version $COMPOSER_VERSION; \
RESULT=$?; \
rm composer-setup.php; \
exit $RESULT
COPY composer.* /var/www/html/
RUN php composer.phar docker-install
COPY . /var/www/html
COPY --from=resources /home/node/app/public /var/www/html/public
USER root
RUN chown -R www-data:www-data \
/var/www/html/public \
/var/www/html/storage \
/var/www/html/bootstrap/cache
USER www-data
ARG APP_COMMIT
ENV APP_COMMIT $APP_COMMIT
ARG APP_VERSION
ENV APP_VERSION $APP_VERSION
RUN php composer.phar docker-build
HEALTHCHECK --start-period=15s --interval=30s --timeout=5s \
CMD \
SCRIPT_NAME=/ping \
SCRIPT_FILENAME=/ping \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:9000 | tee /dev/stderr | grep pong || exit 1
COPY ./docker/php-fpm-entrypoint.sh /var/www/html/entrypoint.sh
ENTRYPOINT ["/var/www/html/entrypoint.sh"]
CMD ["php-fpm"]