-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
163 lines (117 loc) · 5.04 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
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
ARG PHP_VERSION=7.4
ARG NODE_VERSION=12.13
ARG NGINX_VERSION=1.16
########################## PHP ##########################
FROM registry.bitbag.shop/bitbag-php-fpm:${PHP_VERSION} AS root_php
ENV COMPOSER_ALLOW_SUPERUSER=1
COPY --from=composer /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
ARG APP_ENV=prod
# copy only specifically what we need
COPY migrations migrations/
COPY bin bin/
COPY src src/
COPY tests/Application/Kernel.php tests/Application/Kernel.php
COPY composer.json ./
RUN set -eux; \
COMPOSER_MEMORY_LIMIT=-1 composer install; \
composer dump-autoload;
WORKDIR /var/www/tests/Application
COPY tests/Application/assets assets/
COPY tests/Application/bin bin/
COPY tests/Application/config config/
COPY tests/Application/public public/
COPY tests/Application/src src/
COPY tests/Application/templates templates/
COPY tests/Application/translations translations/
COPY tests/Application/.env ./.env
COPY tests/Application/.env.test ./.env.test
COPY tests/Application/composer.json ./
COPY .docker/php/php.ini /usr/local/etc/php/php.ini
COPY .docker/php/php-cli.ini /usr/local/etc/php/php-cli.ini
RUN set -eux; \
composer install; \
composer dump-autoload; \
mkdir -p var/cache var/log; \
chmod +x bin/console; sync;
RUN set -eux; \
php bin/console assets:install; \
php bin/console sylius:install:assets;
VOLUME /var/www/tests/Application/var
VOLUME /var/www/tests/Application/public/media
COPY .docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
########################## NODE ##########################
FROM node:${NODE_VERSION}-alpine AS nodejs
RUN set -eux; \
apk add --no-cache --virtual .build-deps \
g++ \
gcc \
git \
make \
python \
;
WORKDIR /var/www
COPY --from=root_php /var/www/vendor ./vendor
COPY package.json webpack.config.js ./
COPY src/Resources/public ./src/Resources/public
COPY src/Resources/assets ./src/Resources/assets
WORKDIR /var/www/tests/Application
# prevent the reinstallation of vendors at every changes in the source code
COPY tests/Application/package.json tests/Application/webpack.config.js tests/Application/.babelrc ./
COPY tests/Application/assets ./assets
COPY tests/Application/gulpfile.babel.js ./
COPY --from=root_php /var/www/tests/Application/public/bundles ./public/bundles
COPY --from=root_php /var/www/tests/Application/vendor ./vendor
RUN set -eux; \
yarn install; \
yarn cache clean
RUN ln -sf /var/www/tests/Application/node_modules /var/www
RUN yarn encore production
COPY .docker/nodejs/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
CMD ["yarn", "watch"]
########################## NGINX ##########################
FROM nginx:${NGINX_VERSION}-alpine AS nginx
COPY .docker/nginx/conf.d/default.conf /etc/nginx/conf.d/
WORKDIR /var/www
COPY --from=root_php /var/www/tests/Application/public public/
COPY --from=nodejs /var/www/tests/Application/public public/
########################## WKHTMLTOPDF ##########################
FROM madnight/docker-alpine-wkhtmltopdf as wkhtmltopdf_image
########################## PHP ##########################
FROM registry.bitbag.shop/bitbag-php-fpm:${PHP_VERSION} AS result_php
RUN apk add --no-cache fcgi;
COPY --from=wkhtmltopdf_image /bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
COPY .docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
COPY .docker/php/docker-healthcheck.sh /usr/local/bin/docker-healthcheck
RUN apk add --no-cache freetype freetype-dev ttf-freefont libxrender libx11
RUN chmod +x /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-healthcheck
RUN { \
echo '[www]'; \
echo 'ping.path = /ping'; \
} | tee /usr/local/etc/php-fpm.d/docker-healthcheck.conf
WORKDIR /var/www
COPY --from=root_php /var/www/src src/
COPY --from=root_php /var/www/migrations migrations/
COPY --from=root_php /var/www/vendor vendor/
COPY --from=root_php /var/www/tests/Application/bin tests/Application/bin/
COPY --from=root_php /var/www/tests/Application/config tests/Application/config/
COPY --from=root_php /var/www/tests/Application/src tests/Application/src/
COPY --from=root_php /var/www/tests/Application/public tests/Application/public/
COPY --from=root_php /var/www/tests/Application/templates tests/Application/templates/
COPY --from=root_php /var/www/tests/Application/translations tests/Application/translations/
COPY --from=root_php /var/www/tests/Application/Kernel.php tests/Application/Kernel.php
COPY --from=root_php /var/www/tests/Application/composer.json tests/Application/composer.json
COPY --from=root_php /var/www/tests/Application/composer.lock tests/Application/composer.lock
COPY --from=nodejs /var/www/tests/Application/public tests/Application/public/
COPY --from=root_php /usr/local/etc/php/php.ini /usr/local/etc/php/php.ini
COPY --from=root_php /usr/local/etc/php/php-cli.ini /usr/local/etc/php/php-cli.ini
RUN touch tests/Application/.env
WORKDIR /var/www/tests/Application
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]