diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index c5999db6..983a7682 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -46,16 +46,20 @@ jobs: id: login-ecr uses: aws-actions/amazon-ecr-login@v1 + - name: Prepare Composer Auth Secret + run: echo '${{ secrets.COMPOSER_AUTH }}' > composer-auth.json + - name: Build and Release uses: docker/bake-action@v2 env: REGISTRY: ${{ steps.login-ecr.outputs.registry }}/${{ env.PROJECT }}-${{ env.STACK }} VERSION: ${{ env.VERSION }} - COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets._GITHUB_AUTH_TOKEN }}"}}' with: push: true files: | ./docker-bake.hcl + secrets: | + composer_auth=./composer-auth.json - name: Download ecs-tool run: | diff --git a/api/composer.lock b/api/composer.test similarity index 100% rename from api/composer.lock rename to api/composer.test diff --git a/docker-bake.hcl b/docker-bake.hcl index a9620f73..854fa39e 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,5 +1,4 @@ // docker-bake.hcl -variable "COMPOSER_AUTH" { default = "" } variable "REGISTRY" { default = "" } variable "VERSION" { default = "latest" } @@ -26,10 +25,6 @@ target "app" { "${REGISTRY}:${tgt}-%s", compact(["latest", VERSION]) ) : [] - - args = { - "COMPOSER_AUTH" = COMPOSER_AUTH - } } target "app-httpd" { diff --git a/docker/Dockerfile b/docker/Dockerfile index 4e921b75..badb2b05 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:1.2 # Base stage FROM php:7.4-fpm-bullseye as base @@ -43,7 +44,7 @@ COPY --chown=www-data:nogroup ./api ./ RUN chown -R www-data:www-data /var/www/html/api RUN mkdir -p ./storage/logs/ && ln -sf /dev/stdout ./storage/logs/laravel-$(date +'%Y-%m-%d').log USER www-data -RUN composer install +RUN composer install --no-cache RUN composer dumpautoload # Continue @@ -56,11 +57,9 @@ RUN echo $(cat /proc/sys/kernel/random/uuid) > /.fleetbase # Setup composer root directory RUN mkdir -p /root/.composer -# Docker image will accept a build-arg named COMPOSER_AUTH -ARG COMPOSER_AUTH - -# If applicable use `COMPOSER_AUTH` build-arg to generate the auth.json file. -RUN if [ -n "$COMPOSER_AUTH" ]; then echo $COMPOSER_AUTH > /root/.composer/auth.json; fi +# Load the secret into the auth.json file. +RUN --mount=type=secret,id=composer_auth,dst=/root/.composer/auth.json \ + cp /root/.composer/auth.json /root/.composer/auth.json # Set environment ARG ENVIRONMENT=production