-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
120 lines (108 loc) · 3.86 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
ARG FRANKENPHP_TAG=latest
# Franken base stage
###############################################################################
FROM dunglas/frankenphp:$FRANKENPHP_TAG AS frankenphp_base
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
ARG NODE_VERSION=
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN \
# Install OS packages
apt-get update; \
apt-get -y --no-install-recommends install \
libnss3-tools \
supervisor \
unzip \
; \
# Configure OS
sed -i '/\[supervisord\]/a user=root' /etc/supervisor/supervisord.conf; \
sed -i '/\[supervisord\]/a nodaemon=true' /etc/supervisor/supervisord.conf; \
sed -i '/^exec "\$@"/i if [ "$1" = "frankenphp" ] && [ "$APP_ENV" = "prod" ] && php bin/console --raw | grep -q "^doctrine:migrations:migrate"; then\n php bin/console doctrine:migrations:migrate --allow-no-migration --no-interaction --no-ansi\nfi\n' /usr/local/bin/docker-php-entrypoint; \
# Install PHP extensions
install-php-extensions \
@composer \
apcu \
gd \
intl \
opcache \
pdo_mysql \
xsl \
zip \
; \
# Configure PHP
{ \
echo apc.enable_cli = 1; \
echo memory_limit = 256M; \
echo opcache.interned_strings_buffer = 16; \
echo opcache.max_accelerated_files = 20000; \
echo opcache.memory_consumption = 256; \
echo realpath_cache_ttl = 600; \
echo session.use_strict_mode = 1; \
echo zend.detect_unicode = 0; \
} >> "$PHP_INI_DIR/conf.d/10-php.ini"; \
# Install Node.js
if [ -n "$NODE_VERSION" ]; then \
curl -fsSL "https://deb.nodesource.com/setup_$NODE_VERSION.x" | bash -; \
apt-get install -y --no-install-recommends nodejs; \
npm install -g yarn; \
fi; \
# Cleanup
apt-get clean; \
rm -rf /var/lib/apt/lists/*
# Franken dev stage
###############################################################################
FROM frankenphp_base AS frankenphp_dev
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
RUN \
# Install OS packages
apt-get update; \
apt-get -y --no-install-recommends install \
git \
gnupg2 \
openssh-client \
; \
# Configure PHP
cp "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"; \
{ \
echo xdebug.client_host = host.docker.internal; \
} >> "$PHP_INI_DIR/conf.d/10-php.ini"; \
# Cleanup
apt-get clean; \
rm -rf /var/lib/apt/lists/*
# Franken prod stage
###############################################################################
FROM frankenphp_base AS frankenphp_prod
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
ENV APP_ENV=prod
ENV APP_RUNTIME=Runtime\\FrankenPhpSymfony\\Runtime
ENV FRANKENPHP_CONFIG="worker ./public/index.php"
RUN \
# Configure PHP
cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"; \
{ \
echo expose_php = 0; \
echo opcache.preload = /app/config/preload.php; \
echo opcache.preload_user = root; \
} >> "$PHP_INI_DIR/conf.d/10-php.ini"
COPY --link config/docker/php.ini $PHP_INI_DIR/conf.d/20-php.ini
COPY --link config/docker/php.prod.ini $PHP_INI_DIR/conf.d/30-php.ini
COPY --link config/docker/supervisor.conf /etc/supervisor/conf.d/app.conf
COPY --link composer.* symfony.* ./
RUN composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
COPY --link . /app
RUN \
mkdir -p var/cache var/log; \
chmod +x bin/console; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer dump-env prod; \
bin/console cache:clear; \
if [ -f package.json ]; then \
if [ -f yarn.lock ]; then \
yarn install --no-progress --frozen-lockfile; \
elif [ -f package-lock.json ]; then \
npm ci --no-progress; \
else \
npm install --no-progress; \
fi; \
npm run build; \
fi; \
sync