This repository has been archived by the owner on Nov 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
150 lines (104 loc) · 2.71 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
FROM php:7.2.11-fpm-alpine AS php
ENV PHP_EXTENSION_DIR=/usr/local/lib/php/extensions/no-debug-non-zts-20170718
#
# Stage: Composer install for production
#
FROM composer:1.7.3 AS composer
COPY composer.json \
composer.lock \
symfony.lock \
./
COPY vendor-extra/ vendor-extra/
RUN composer --no-interaction install --no-dev --ignore-platform-reqs --no-autoloader --no-suggest --prefer-dist
COPY src/ src/
RUN composer --no-interaction dump-autoload --classmap-authoritative
#
# Stage: Production environment
#
FROM php AS prod
WORKDIR /app
ENV APP_ENV=prod
RUN mkdir data var && \
chown www-data:www-data var
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS && \
apk add --no-cache \
icu-dev \
&& \
docker-php-ext-install \
intl \
opcache \
&& \
apk del .build-deps && \
rm -rf /var/cache/apk/
COPY LICENSE .
COPY .docker/php.ini ${PHP_INI_DIR}/conf.d/00-app.ini
COPY bin/ bin/
COPY src/ src/
COPY public/ public/
COPY templates/ templates/
COPY config/ config/
COPY --from=composer /app/vendor/ vendor/
COPY vendor-extra/ vendor-extra/
RUN bin/console assets:install && \
rm -rf var/*
USER www-data
HEALTHCHECK --interval=5s CMD sh -c 'nc -z localhost 9000'
ARG revision
LABEL org.opencontainers.image.revision=${revision}
#
# Stage: Composer install for development
#
FROM composer AS composer-dev
RUN composer --no-interaction install --ignore-platform-reqs --no-suggest --prefer-dist
#
# Stage: Test environment
#
FROM prod AS test
ENV APP_ENV=test
USER root
COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN touch .phpcs-cache && \
chown www-data:www-data .phpcs-cache
COPY .docker/php-test.ini ${PHP_INI_DIR}/conf.d/01-app.ini
COPY tests/ tests/
COPY composer.json \
composer.lock \
phpcs.xml.dist \
phpstan.neon.dist \
phpunit.xml.dist \
symfony.lock \
./
COPY --from=composer-dev /app/vendor/ vendor/
RUN bin/console assets:install && \
rm -rf var/*
USER www-data
#
# Stage: Development environment
#
FROM test AS dev
ENV APP_ENV=dev
USER root
ENV COMPOSER_ALLOW_SUPERUSER=true
COPY .docker/php-dev.ini ${PHP_INI_DIR}/conf.d/02-app.ini
RUN bin/console assets:install && \
rm -rf var/*
#
# Stage: Install Xdebug
#
FROM php AS xdebug
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS && \
pecl install \
xdebug-2.7.0 \
&& \
docker-php-ext-enable \
xdebug \
&& \
apk del .build-deps && \
rm -rf /var/cache/apk/
#
# Stage: Debug environment
#
FROM dev AS debug
COPY --from=xdebug ${PHP_EXTENSION_DIR}/*.so ${PHP_EXTENSION_DIR}/
COPY --from=xdebug ${PHP_INI_DIR}/conf.d/*.ini ${PHP_INI_DIR}/conf.d/
COPY .docker/php-debug.ini ${PHP_INI_DIR}/conf.d/03-app.ini