generated from Monogramm/project-template
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile.alpine
334 lines (311 loc) · 9.79 KB
/
Dockerfile.alpine
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
FROM php:7.4-cli AS builder
ARG COMPOSER_VERSION=2.0.11
# install the packages we need
# Install npm
# Install composer
# Install yarn
RUN set -ex; \
apt-get update -q; \
apt-get install -y --no-install-recommends \
netcat \
openssl \
rsync \
unzip \
wget \
zip \
; \
apt-get install -y --no-install-recommends \
apt-transport-https \
curl \
git \
gnupg \
libcurl4-openssl-dev \
libfreetype6-dev \
libgpgme11 \
libgpgme11-dev \
libicu-dev \
libjpeg-dev \
libldap2-dev \
libonig-dev \
libpng-dev \
libpq-dev \
librabbitmq-dev \
libsodium-dev \
libxml2-dev \
libzip-dev \
unzip \
wget \
zip \
zlib1g-dev \
; \
curl -sL 'https://deb.nodesource.com/setup_12.x' -o nodesource_setup.sh ; \
bash nodesource_setup.sh; \
apt-get install -y \
nodejs \
; \
npm --version; \
curl --silent --show-error "https://getcomposer.org/installer" -o composer-setup.php; \
php composer-setup.php --install-dir=/usr/local/bin --filename=composer "--version=${COMPOSER_VERSION}"; \
composer --version; \
pecl install gnupg; \
docker-php-ext-enable gnupg; \
docker-php-ext-configure zip; \
echo "\n" | pecl install apcu; \
docker-php-ext-enable apcu; \
echo "apc.enable_cli=1" >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \
pecl install amqp; \
docker-php-ext-enable amqp; \
pecl install -o -f redis; \
docker-php-ext-enable redis; \
pecl install libsodium; \
docker-php-ext-enable sodium; \
yes | pecl install xdebug; \
echo "xdebug.mode=coverage\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
"xdebug.idekey=\"DOCKER\"\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
"xdebug.client_port=9003\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
docker-php-ext-enable xdebug; \
docker-php-ext-install -j "$(nproc)" \
bcmath \
gd \
intl \
ldap \
mbstring \
opcache \
pdo \
soap \
sockets \
zip \
; \
curl -sS "https://dl.yarnpkg.com/debian/pubkey.gpg" | apt-key add - ; \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \
wget 'https://get.symfony.com/cli/installer' -O - | bash; \
mv /root/.symfony/bin/symfony /usr/local/bin/symfony; \
symfony -V; \
apt-get update -q; \
apt-get install -y \
yarn \
; \
yarn --version
ARG APP_PATH=./app
COPY ${APP_PATH} /usr/src/symfony
# Arguments to label built container
ARG VCS_REF=unknown
ARG BUILD_DATE=unknown
ARG VERSION=0.1.0
ARG APP_PUBLIC_URL=http://localhost:80
ARG WEBSITE_PUBLIC_URL=http://localhost:80
RUN set -ex; \
sed -i \
-e "s|APP_PUBLIC_URL=.*|APP_PUBLIC_URL=${APP_PUBLIC_URL}/|g" \
-e "s|WEBSITE_PUBLIC_URL=.*|WEBSITE_PUBLIC_URL=${WEBSITE_PUBLIC_URL}/|g" \
/usr/src/symfony/.env.vue
WORKDIR /usr/src/symfony
ARG APP_ENV=prod
ARG YARN_ENV=production
ARG STORIES=false
ARG EXPORT_TESTS_RESULTS=false
ARG PHP_MEMORY_LIMIT=256M
# Install the project
# Clear any cache that might still be remaining
# Compile assets for production
RUN set -ex; \
mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"; \
sed -i -e 's|memory_limit = .*|memory_limit = ${PHP_MEMORY_LIMIT}|g' "$PHP_INI_DIR/php.ini"; \
\
composer \
--prefer-dist \
--no-interaction \
--no-ansi --no-progress \
--optimize-autoloader --apcu-autoloader \
install \
; \
\
yarn install \
--no-progress \
--non-interactive \
; \
npm install \
--non-interactive \
; \
\
php bin/console cache:clear --env=${APP_ENV}; \
php bin/console cache:warmup --env=${APP_ENV}; \
\
yarn run encore ${YARN_ENV}; \
test "${STORIES}" = "false" || npm run build-storybook; \
\
php bin/console lint:twig --no-ansi --no-interaction ./templates; \
php bin/console doctrine:migrations:migrate --no-interaction --env=test; \
php bin/console doctrine:fixtures:load --no-interaction --env=test; \
php bin/phpunit --do-not-cache-result --no-interaction \
--coverage-clover /tmp/coverage-phpunit-clover.xml \
--coverage-cobertura /tmp/coverage-phpunit-cobertura.xml \
--coverage-html /tmp/coverage-phpunit-html \
--coverage-text --colors=never \
; \
./vendor/bin/phpcs --no-colors --warning-severity=0; \
./vendor/bin/psalm -m --no-file-cache --no-progress; \
npx eslint --no-color ./assets/; \
\
rm -rf ./node_modules ./var/*; \
mkdir -p /usr/src/symfony/.docker; \
[ "${EXPORT_TESTS_RESULTS}" = "false" ] || cp -r /tmp/coverage-* /usr/src/symfony/.docker/; \
echo "${BUILD_DATE}" > '/usr/src/symfony/.docker/build-date'; \
echo "${VERSION} ${VCS_REF} ${BUILD_DATE}" > '/usr/src/symfony/.docker/build'
# Once application has been built, prepare production image
FROM php:7.4-fpm-alpine
# install the packages we need
# install the PHP extensions we need
# configure the PHP extensions
# use PHP production config
# give access to www-data on the site files
RUN set -ex; \
apk add --no-cache \
gpgme \
icu \
libldap \
libpng \
libpq \
libsodium \
libzip \
openssl \
rabbitmq-c \
rsync \
shadow \
unzip \
wget \
zlib \
; \
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
g++ \
curl-dev \
freetype-dev \
icu-dev \
libjpeg-turbo-dev \
libsodium-dev \
libxml2-dev \
libzip-dev \
make \
oniguruma-dev \
openldap-dev \
postgresql-dev \
rabbitmq-c-dev \
zlib-dev \
; \
docker-php-ext-configure ldap; \
docker-php-ext-configure gd; \
docker-php-ext-configure intl; \
docker-php-ext-configure zip; \
echo "\n" | pecl install apcu; \
docker-php-ext-enable apcu; \
echo "apc.enable_cli=1" >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \
pecl install amqp; \
docker-php-ext-enable amqp; \
pecl install -o -f redis; \
docker-php-ext-enable redis; \
pecl install libsodium; \
docker-php-ext-enable sodium; \
docker-php-ext-install -j "$(nproc)" \
bcmath \
gd \
intl \
ldap \
mbstring \
mysqli \
opcache \
pdo \
pdo_mysql \
pdo_pgsql \
pgsql \
soap \
sockets \
zip \
; \
\
pecl clear-cache; \
apk --purge del .build-deps; \
rm -rf /var/cache/apk/*; \
\
chown -R www-data:root /var/www/html; \
chmod -R g=u /var/www/html; \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
ENV DATABASE_DRIVER=postgresql \
DATABASE_VERSION=10 \
DATABASE_OPTIONS= \
DATABASE_HOST= \
DATABASE_PORT= \
DATABASE_NAME=app_db \
DATABASE_USERNAME=root \
DATABASE_PASSWORD= \
MAILER_TRANSPORT=smtp \
MAILER_HOST= \
MAILER_USER= \
MAILER_PASSWORD= \
SF_PROD=true \
SF_ADMIN_LOGIN= \
SF_ADMIN_EMAIL= \
SF_ADMIN_PASSWD= \
SF_SERVER_PUBLIC_URL=http://localhost:80 \
SF_WEBSITE_PUBLIC_URL=http://localhost:80 \
SF_FACEBOOK_URL=# \
SF_TWITTER_URL=# \
SF_LINKEDIN_URL=# \
SF_YOUTUBE_URL=# \
SF_CLEAR_CACHE= \
APP_ENV=prod \
WWW_USER_ID=82 \
WWW_GROUP_ID=82 \
PHP_INI_DATE_TIMEZONE='UTC' \
PHP_MEMORY_LIMIT=256M \
PHP_MAX_UPLOAD=20M \
PHP_MAX_EXECUTION_TIME=300
COPY --from=builder /usr/src/symfony /usr/src/symfony
COPY ./cron/15min /etc/periodic/15min
COPY ./cron/hourly /etc/periodic/hourly
COPY ./cron/daily /etc/periodic/daily
COPY ./cron/weekly /etc/periodic/weekly
COPY ./cron/monthly /etc/periodic/monthly
VOLUME /var/www/html
COPY entrypoint.sh /
RUN set -ex; \
chmod 755 /entrypoint.sh;
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
WORKDIR /var/www/html/
# Arguments to label built container
ARG VCS_REF=unknown
ARG BUILD_DATE=unknown
ARG VERSION=0.1.0
ARG APP_PUBLIC_URL=http://localhost:8080
# Keep track of image version
RUN set -ex; \
sed -i \
-e "s|http://localhost/|${APP_PUBLIC_URL}/|g" \
-e "s|lastmod>.*</lastmod|lastmod>${BUILD_DATE}</lastmod|g" \
/usr/src/symfony/public/robots.txt \
/usr/src/symfony/public/sitemap.xml \
;
# Container labels (http://label-schema.org/)
# Container annotations (https://github.com/opencontainers/image-spec)
LABEL maintainer="Monogramm Maintainers <opensource at monogramm dot io>" \
product="Vue Symfony Starter" \
version=$VERSION \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/Monogramm/vue-symfony-starter/" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Vue Symfony Starter" \
org.label-schema.description="A 'simple' starter project using Vue.js and Symfony." \
org.label-schema.url="${APP_PUBLIC_URL}/" \
org.label-schema.vendor="Monogramm" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.source="https://github.com/Monogramm/vue-symfony-starter/" \
org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.title="Vue Symfony Starter" \
org.opencontainers.image.description="A 'simple' starter project using Vue.js and Symfony." \
org.opencontainers.image.url="${APP_PUBLIC_URL}/" \
org.opencontainers.image.vendor="Monogramm" \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.authors="Monogramm Maintainers <opensource at monogramm dot io>"