From 4d7536db7c4b73ef317b6a99dede3050b1fed674 Mon Sep 17 00:00:00 2001 From: Sigri44 Date: Fri, 12 Sep 2025 21:57:05 +0200 Subject: [PATCH] Clean Dockerfile & CI/CD --- .github/workflows/branch.yml | 5 +++-- Dockerfile | 19 +++++++++---------- docker-compose-branch.yml | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/branch.yml b/.github/workflows/branch.yml index 6a371d5..01620a7 100644 --- a/.github/workflows/branch.yml +++ b/.github/workflows/branch.yml @@ -3,10 +3,8 @@ name: Symfony deployment on: push: branches: [ "alpha" ] -# branches: [ "feature/upgrade_symfony" ] pull_request: branches: [ "alpha" ] -# branches: [ "feature/upgrade_symfony" ] permissions: contents: read @@ -119,10 +117,13 @@ jobs: run: | if [[ "$DOCKER_BRANCH" == "master" ]]; then export HOSTNAME="api.$DOMAIN_URL" + export APP_ENV="prod" elif [[ "$DOCKER_BRANCH" == "preprod" ]]; then export HOSTNAME="api.$DOCKER_BRANCH.$DOMAIN_URL" + export APP_ENV="prod" else export HOSTNAME="api.$DOCKER_BRANCH.$DOMAIN_URL" + export APP_ENV="dev" fi ssh staging 'export DOCKER_BRANCH=${{ github.ref_name }} DOCKER_REGISTRY=${{ secrets.DOCKER_REGISTRY }} cd /var/docker/api/${DOCKER_BRANCH} diff --git a/Dockerfile b/Dockerfile index e9582a6..351d7db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,23 @@ FROM registry.realtoken.community/docker-symfony-php:8.4 -# Composer WORKDIR /var/www/html COPY . ./ -RUN cp .env.dev .env + +# Composer install sans .env RUN composer install --prefer-dist --no-interaction --optimize-autoloader --no-progress +#ARG APP_ENV=prod +ENV APP_ENV=${APP_ENV} +RUN composer dump-env ${APP_ENV} +RUN composer run-script --no-dev post-install-cmd + # HTTPS ENV HTTPS=false # Nginx COPY docker/nginx.conf /etc/nginx/nginx.conf -#COPY docker/blockips.conf /etc/nginx/blockips.conf - -RUN mkdir -p var/cache/prod -RUN chmod -R 777 var/cache/prod -# PHP -## Remove fastcgi log debug -#RUN echo 'fastcgi.logging=0' >> "/etc/php7/php.ini" -#RUN echo 'fastcgi.logging=0' >> "/etc/php8/php.ini" +RUN mkdir -p var/cache/${APP_ENV} +RUN chmod -R 777 var/cache/${APP_ENV} CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/docker-compose-branch.yml b/docker-compose-branch.yml index 0088b0c..cc5e54b 100644 --- a/docker-compose-branch.yml +++ b/docker-compose-branch.yml @@ -4,6 +4,8 @@ services: container_name: ${DOCKER_BRANCH}-api_php-sf build: context: ./ + args: + APP_ENV: ${APP_ENV} networks: - api-${DOCKER_BRANCH} - traefik-realt @@ -51,4 +53,3 @@ networks: api-${DOCKER_BRANCH}: traefik-realt: external: true -