forked from phpdocker-io/phpdocker.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
85 lines (63 loc) · 2.54 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
###########
# Backend #
###########
# Base container for dev & deployment
FROM phpdockerio/php:8.1-fpm AS backend-base
WORKDIR "/application"
RUN apt-get update; \
apt-get -y --no-install-recommends install \
php8.1-intl \
php8.1-redis; \
apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
FROM backend-base as backend-dev
RUN apt-get update; \
apt-get -y --no-install-recommends install php8.1-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
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/8.1/fpm/conf.d/z-overrides.ini
COPY infrastructure/php-fpm/opcache-prod.ini /etc/php/8.1/fpm/conf.d/z-opcache.ini
COPY infrastructure/php-fpm/php-fpm-pool-prod.conf /etc/php/8.1/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 dump-autoload --optimize --classmap-authoritative --no-scripts; \
bin/console cache:warmup; \
chown www-data:www-data var/ -Rf
############
# Frontend #
############
# Run bower install before we can install bundle's assets
FROM node:alpine AS bower-installer
COPY bower.json .
COPY .bowerrc .
RUN apk add git --no-cache; \
npm i -g bower; \
bower install --allow-root
## Actual deployable frontend image
FROM nginx:alpine AS frontend-deployment
#FROM phpdockerio/nginx-pagespeed:latest AS frontend-deployment
WORKDIR /application
RUN mkdir ./web; \
touch ./web/app.php
#COPY infrastructure/nginx/pagespeed.conf /etc/nginx/pagespeed.conf
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=bower-installer public/vendor public/vendor
COPY public/css public/css
COPY public/js public/js