-
Notifications
You must be signed in to change notification settings - Fork 101
/
Dockerfile
90 lines (64 loc) · 2.65 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
ARG PHP_VERSION=8.3
###########
# Backend #
###########
# Base container for dev & deployment
FROM phpdockerio/php:${PHP_VERSION}-fpm AS backend-base
WORKDIR "/application"
ARG PHP_VERSION
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
php${PHP_VERSION}-intl \
php${PHP_VERSION}-redis \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
FROM backend-base as backend-dev
ARG PHP_VERSION
RUN apt-get update \
&& apt-get -y --no-install-recommends install php${PHP_VERSION}-xdebug \
&& phpdismod xdebug \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Pre-deployment container. The deployed container needs some files generated by yarn
FROM backend-base AS backend-deployment
ARG PHP_VERSION
ENV APP_ENV=prod
ENV SYMFONY_ENV=prod
ENV APP_SECRET=""
ENV GOOGLE_ANALYTICS=""
COPY bin/console /application/bin/
COPY composer.* /application/
RUN composer install --no-dev --no-scripts \
&& composer clear-cache
COPY infrastructure/php-fpm/php-ini-overrides.ini /etc/php/${PHP_VERSION}/fpm/conf.d/z-overrides.ini
COPY infrastructure/php-fpm/opcache-prod.ini /etc/php/${PHP_VERSION}/fpm/conf.d/z-opcache.ini
COPY infrastructure/php-fpm/php-fpm-pool-prod.conf /etc/php/${PHP_VERSION}/fpm/pool.d/z-optimised.conf
COPY config ./config
COPY src ./src
COPY templates ./templates
COPY public/index.php ./public/
RUN touch ./.env
RUN COMPOSER_ALLOW_SUPERUSER=1 composer dump-autoload --optimize --classmap-authoritative --no-scripts \
&& bin/console cache:warmup \
&& chown www-data:www-data var/ -Rf
############
# Frontend #
############
# For some reason, yarn install hangs on node:alpine when building for ARM, so use the normal image instead
# Bigger and slower unfortunately but it works
FROM node:latest AS frontend-installer
COPY package.json .
COPY yarn.lock .
RUN yarn install --immutable
## Actual deployable frontend image
FROM nginx:alpine AS frontend-deployment
WORKDIR /application
COPY infrastructure/nginx/nginx.conf /etc/nginx/conf.d/default.conf
# NGINX config: update php-fpm hostname to localhost (same pod in k8s), activate pagespeed config, deactivate SSL
RUN sed -i "s/php-fpm/localhost/g" /etc/nginx/conf.d/default.conf \
&& sed -i "s/# %DEPLOYMENT //g" /etc/nginx/conf.d/default.conf \
&& sed -i "s/listen 443/#listen 443/g" /etc/nginx/conf.d/default.conf \
&& sed -i "s/ssl_/#ssl_/g" /etc/nginx/conf.d/default.conf
COPY --from=frontend-installer node_modules/@bower_components public/vendor
COPY public/css public/css
COPY public/js public/js