Skip to content

Commit

Permalink
Revert "[Docker] improve build image (#11262)"
Browse files Browse the repository at this point in the history
This reverts commit 9b719e9.
  • Loading branch information
ottaviano authored Jan 6, 2025
1 parent e39b10b commit a3a00de
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 37 deletions.
5 changes: 1 addition & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
**/docker-compose.*.yml
**/docker-compose.yaml
**/docker-compose.yml
**/compose.*.yaml
**/compose.*.yml
**/compose.yaml
**/compose.yml
**/Dockerfile
**/Thumbs.db
.github/
Expand All @@ -36,6 +32,7 @@ vendor/
.idea
.tmp
app/
docker-dev.md5
.php_cs.*
features
Makefile
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ runs:
--cache-from=$REGISTRY:$TAG-$HASH \
--cache-from=$REGISTRY:$TAG \
--tag=$REGISTRY:$TAG-$HASH \
--target=php_caddy_prod \
--target=php_caddy \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg BUILD_DEV=1 \
--compress \
.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
DOCKER_BUILDKIT: 1
DOCKER_COMPOSE_ARGS: -f compose.yml -f compose.ci.yml
DOCKER_COMPOSE_ARGS: -f docker-compose.yml -f docker-compose.ci.yml
EXEC_ARGS: -T
# Update this to force cache reset
CACHE_KEY: ${{ secrets.CACHE_KEY }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
/public/built/
/public/select2/
/.tmp
/compose.override.yml
/docker-compose.override.yml
/gcloud-service-key.json
/npm-debug.log
/phpunit.xml
/.phpunit.result.cache
/yarn-error.log
/.php_cs
/.docker-dev.md5
/behat.yml
/docker-dev.lock
docker-dev.md5
node_modules
.idea
/.env.local
Expand Down
41 changes: 16 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

ARG CADDY_VERSION=2
# Fix the version of PHP to avoid this bug https://github.com/php/php-src/issues/14480
ARG PHP_VERSION=8.3
ARG PHP_VERSION=8.3.7
ARG NODE_VERSION=18

FROM node:${NODE_VERSION}-alpine AS node
Expand All @@ -21,6 +21,8 @@ ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr_FR.UTF-8
ENV LC_ALL fr_FR.UTF-8

ARG BUILD_DEV

WORKDIR /srv/app

# php extensions installer: https://github.com/mlocati/docker-php-extension-installer
Expand Down Expand Up @@ -58,7 +60,9 @@ RUN apk add --no-cache tzdata && \
echo "Europe/Paris" > /etc/timezone && \
apk del tzdata

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY --link docker/php/conf.d/default.ini $PHP_INI_DIR/conf.d/
COPY --link docker/php/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/app.ini

COPY --link docker/php/php-fpm.d/zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf
RUN mkdir -p /var/run/php
Expand All @@ -79,33 +83,20 @@ COPY --link --from=composer/composer:2-bin /composer /usr/bin/composer

COPY --link . .

RUN test -z "$BUILD_DEV" && ( \
set -eux; \
mkdir -p var/cache var/log; \
composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer dump-env prod; \
composer run-script --no-dev post-install-cmd; \
rm -rf /root/.composer; \
chmod +x bin/console; sync \
) || :

COPY --link --from=caddy /usr/bin/caddy /usr/bin/caddy
COPY --link docker/caddy/Caddyfile /etc/caddy/Caddyfile

EXPOSE 80

CMD ["multirun", "docker-entrypoint php-fpm -F -R", "caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"]

FROM php_caddy AS php_caddy_dev

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
COPY --link docker/php/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/app.ini

RUN set -eux; \
install-php-extensions \
xdebug \
;

FROM php_caddy AS php_caddy_prod

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY --link docker/php/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/app.ini

RUN set -eux; \
mkdir -p var/cache var/log; \
composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer dump-env prod; \
composer run-script --no-dev post-install-cmd; \
rm -rf /root/.composer; \
chmod +x bin/console; sync
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ services:
app:
build:
context: .
target: php_caddy_dev
target: php_caddy
args:
BUILD_DEV: true
restart: unless-stopped
networks:
default:
Expand Down
2 changes: 1 addition & 1 deletion docker/php/conf.d/app.dev.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
; The `client_host` below may optionally be replaced with `discover_client_host=yes`
; Add `start_with_request=yes` to start debug session on each request
xdebug.client_host = 'host.docker.internal'
opcache.enable = 0
opcache.enable = Off
6 changes: 3 additions & 3 deletions docker/php/conf.d/default.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
memory_limit = -1
short_open_tag = 0
expose_php = 0
short_open_tag = Off
expose_php = Off
date.timezone = Europe/Paris
apc.enable_cli = 1
apc.enable_cli = On
session.use_strict_mode = 1
zend.detect_unicode = 0
intl.default_locale = fr
Expand Down

0 comments on commit a3a00de

Please sign in to comment.