Skip to content

Commit 59bf2d6

Browse files
committed
refacto(docker): Init .dockerignore + Fix the version of composer + fix prod php ini
1 parent bc43b90 commit 59bf2d6

File tree

4 files changed

+30
-23
lines changed

4 files changed

+30
-23
lines changed

.docker/php/conf.d/20-app.prod.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
opcache.preload_user = www-data
2-
opcache.preload = /srv/config/preload.php
2+
;opcache.preload = /var/www/html/config/preload.php
33
opcache.validate_timestamps = 0

.docker/php/docker-entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if [ "$1" = 'apache2-foreground' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console'
2020
git config --global --add safe.directory /var/www/html
2121
fi
2222

23-
composer install --prefer-dist --no-progress --no-interaction --no-scripts
23+
mkdir -p var/cache var/logs var/sessions;
2424
fi
2525

2626
setfacl -R -m u:www-data:rwX -m u:localUser:rwX var
@@ -31,4 +31,4 @@ if [ "$1" = 'bash' ] || [ "$1" = 'composer' ]; then
3131
exec gosu ${user} docker-php-entrypoint "$@"
3232
else
3333
exec docker-php-entrypoint "$@"
34-
fi
34+
fi

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data/

Dockerfile

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ ARG GID=1008
55

66
WORKDIR /var/www/html
77

8-
VOLUME /var/www/html/var
9-
108
# Update package list and install system dependencies
119
RUN apt-get update \
1210
&& apt-get install -y --no-install-recommends \
@@ -26,7 +24,7 @@ RUN groupadd -g ${GID} localUser && \
2624
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
2725

2826
RUN set -eux; \
29-
install-php-extensions @composer zip intl pdo_mysql mysqli gd opcache pcntl \
27+
install-php-extensions @composer-2.2.25 zip intl pdo_mysql mysqli gd opcache pcntl \
3028
;
3129

3230
COPY --link .docker/php/conf.d/10-app.ini $PHP_INI_DIR/conf.d/
@@ -36,31 +34,33 @@ HEALTHCHECK --start-period=1m CMD docker-healthcheck
3634

3735
COPY --link --chmod=755 .docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
3836

39-
COPY --link .docker/apache/apache.conf /etc/apache2/sites-available/000-default.conf
40-
COPY --link .docker/apache/cert/apache.crt /etc/apache2/ssl/apache.crt
41-
COPY --link .docker/apache/cert/apache.key /etc/apache2/ssl/apache.key
42-
43-
RUN sed --in-place "s/User \${APACHE_RUN_USER}/User localUser/" /etc/apache2/apache2.conf && \
44-
sed --in-place "s/Group \${APACHE_RUN_GROUP}/Group localUser/" /etc/apache2/apache2.conf && \
45-
a2ensite 000-default && \
46-
a2enmod rewrite ssl
47-
4837
ENTRYPOINT ["docker-entrypoint"]
4938
CMD ["apache2-foreground"]
5039

5140
FROM afup_web_base AS afup_web_dev
5241

53-
ENV APP_ENV=dev
54-
5542
COPY --link .docker/php/conf.d/20-app.dev.ini $PHP_INI_DIR/conf.d/
5643

5744
RUN set -eux; \
5845
install-php-extensions xdebug \
5946
;
6047

61-
FROM afup_web_base AS afup_web_prod
48+
COPY --link .docker/apache/apache.conf /etc/apache2/sites-available/000-default.conf
49+
COPY --link .docker/apache/cert/apache.crt /etc/apache2/ssl/apache.crt
50+
COPY --link .docker/apache/cert/apache.key /etc/apache2/ssl/apache.key
51+
52+
RUN sed --in-place "s/User \${APACHE_RUN_USER}/User localUser/" /etc/apache2/apache2.conf && \
53+
sed --in-place "s/Group \${APACHE_RUN_GROUP}/Group localUser/" /etc/apache2/apache2.conf && \
54+
a2ensite 000-default && \
55+
a2enmod rewrite ssl
56+
57+
FROM afup_web_base AS afup_web_prod_base
58+
59+
VOLUME /var/www/html/var
6260

6361
ENV APP_ENV=prod
62+
ENV SYMFONY_ENV=prod
63+
ENV COMPOSER_ALLOW_SUPERUSER=1
6464

6565
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
6666
COPY --link .docker/php/conf.d/20-app.prod.ini $PHP_INI_DIR/conf.d/
@@ -76,9 +76,8 @@ RUN set -eux; \
7676
COPY --link . ./
7777

7878
RUN set -eux; \
79-
mkdir -p var/cache var/log var/sessions; \
79+
mkdir -p var/cache var/logs var/sessions; \
8080
composer dump-autoload --classmap-authoritative --no-dev; \
81-
composer dump-env prod; \
8281
composer run-script --no-dev post-install-cmd; \
8382
chmod +x bin/console; sync;
8483

@@ -88,11 +87,18 @@ WORKDIR /var/www/html
8887

8988
COPY --link ./package.json ./package-lock.json ./webpack.config.js ./
9089

91-
COPY --from=afup_web_prod ./var/www/html/htdocs ./htdocs
92-
COPY --from=afup_web_prod ./var/www/html/vendor ./vendor
90+
COPY --from=afup_web_prod_base ./var/www/html/htdocs ./htdocs
91+
COPY --from=afup_web_prod_base ./var/www/html/sources ./sources
92+
93+
COPY --from=afup_web_prod_base ./var/www/html/vendor ./vendor
9394

9495
ENV NODE_ENV=prod
9596

9697
RUN set -eux; \
9798
npm install --legacy-peer-deps; \
98-
npm run build;
99+
npm run build;
100+
101+
FROM afup_web_prod_base AS afup_web_prod
102+
103+
COPY --from=afup_web_assets ./var/www/html/htdocs ./htdocs
104+
COPY --from=afup_web_assets ./var/www/html/sources ./sources

0 commit comments

Comments
 (0)