forked from Cap-Coding/symfony_docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile_prod
81 lines (64 loc) · 2.43 KB
/
Dockerfile_prod
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
ARG PHP_VERSION=7.4.14
ARG NGINX_VERSION=1.18
FROM php:${PHP_VERSION}-fpm-alpine AS app_php
ARG WORKDIR=/app
RUN docker-php-source extract \
&& apk add --update --virtual .build-deps autoconf g++ make pcre-dev icu-dev openssl-dev libxml2-dev libmcrypt-dev git libpng-dev \
# Install pgsql goodness
&& apk add postgresql-dev \
&& docker-php-ext-install pgsql pdo_pgsql \
&& apk del postgresql-libs libsasl db \
# Instaling pecl modules
&& pecl install apcu \
# Enable pecl modules
&& docker-php-ext-enable apcu opcache \
# Installing intl
&& apk add icu-libs icu \
&& docker-php-ext-install intl \
# Post run
&& runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)" \
&& apk add --no-cache --virtual .app-phpexts-rundeps $runDeps \
&& pecl clear-cache \
&& docker-php-source delete \
&& apk del --purge .build-deps \
&& rm -rf /tmp/pear \
&& rm -rf /var/cache/apk/*
COPY --from=composer:1 /usr/bin/composer /usr/local/bin/composer
COPY docker/php/php.prod.ini $PHP_INI_DIR/conf.d/php.ini
COPY docker/php/php-cli.prod.ini $PHP_INI_DIR/conf.d/php-cli.ini
RUN mkdir -p ${WORKDIR}
WORKDIR ${WORKDIR}
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN set -eux; \
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
composer clear-cache
# prevent the reinstallation of vendors at every changes in the source code
COPY composer.json composer.lock symfony.lock ./
RUN set -eux; \
composer install --prefer-dist --no-autoloader --no-scripts --no-progress --no-suggest; \
composer clear-cache
COPY .env ./
COPY bin bin/
COPY config config/
COPY src src/
COPY public public/
RUN set -eux \
&& mkdir -p var/cache var/log \
&& composer dump-autoload --classmap-authoritative \
&& APP_SECRET='' composer run-script post-install-cmd
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
RUN chown www-data:www-data -R ${WORKDIR}/var/* ${WORKDIR}/vendor/*
USER www-data
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
FROM nginx:${NGINX_VERSION}-alpine AS app_nginx
COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/
WORKDIR /app/public
COPY --from=app_php /app/public public/