-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
131 lines (107 loc) · 3.05 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
121
122
123
124
125
126
127
128
129
130
131
ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-alpine AS infection_nodejs
WORKDIR /srv/app
# prevent the reinstallation of vendors at every changes in the source code
COPY app/package.json app/yarn.lock ./
RUN set -eux; \
yarn install; \
yarn cache clean
COPY app/bin bin/
COPY app/assets assets/
COPY app/config config/
COPY app/public public/
COPY app/templates templates/
COPY app/src src/
COPY app/webpack.config.js ./
COPY app/postcss.config.js ./
COPY app/tailwind.config.js ./
RUN set -eux; \
yarn build
COPY nodejs/docker-nodejs-entrypoint.sh /usr/local/bin/docker-nodejs-entrypoint
RUN chmod +x /usr/local/bin/docker-nodejs-entrypoint
ENTRYPOINT ["docker-nodejs-entrypoint"]
CMD ["yarn", "watch"]
FROM php:8.2-fpm-alpine3.17 as prod
# persistent / runtime deps
RUN apk add --no-cache \
acl \
fcgi \
file \
gettext \
git \
ffmpeg \
;
RUN set -eux; \
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
icu-dev \
libzip-dev \
mysql-dev \
zlib-dev \
; \
\
git clone https://github.com/bematech/libmpdec.git \
&& cd libmpdec \
&& ./configure \
&& make \
&& make install \
&& cd ..; \
\
docker-php-ext-configure zip; \
docker-php-ext-install -j$(nproc) \
intl \
pdo_mysql \
zip \
bcmath \
; \
pecl install \
apcu-5.1.22 \
pcov \
; \
pecl clear-cache; \
docker-php-ext-enable \
apcu \
opcache \
bcmath \
pcov \
; \
\
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --no-cache --virtual .api-phpexts-rundeps $runDeps; \
\
apk del .build-deps; \
apk add make \
;
COPY php/php.ini /usr/local/etc/php/php.ini
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV PATH="${PATH}:/root/.composer/vendor/bin"
WORKDIR /app
COPY app .
COPY --from=infection_nodejs /srv/app/public/build/manifest.json /app/public/build/manifest.json
COPY --from=infection_nodejs /srv/app/public/build/entrypoints.json /app/public/build/entrypoints.json
ARG APP_ENV=prod
RUN mkdir -p var/cache var/logs var/sessions \
&& composer install --prefer-dist --no-dev --no-scripts --no-progress --no-suggest --classmap-authoritative --no-interaction \
&& composer dump-autoload --optimize --classmap-authoritative --no-dev \
&& composer run-script --no-dev post-install-cmd \
&& chmod +x bin/console && sync \
&& composer clear-cache \
&& chown -R www-data var \
&& chown -R www-data infection-builds
COPY --link php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
# "nginx" production stage
# depends on the nodjs - copies assets from there
FROM nginx:1.17-alpine AS infection_nginx_prod
COPY ./nginx/prod/conf.d/default.conf /etc/nginx/conf.d/default.conf
WORKDIR /app/public
COPY --from=infection_nodejs /srv/app/public ./