From f8c07c63b378ac2db09e5ec9a26e5cbabac5ab48 Mon Sep 17 00:00:00 2001 From: Sergio Laverde Date: Thu, 9 Jan 2025 16:53:37 -0500 Subject: [PATCH 1/3] chore: update deprecated actions and pin ubuntu version The older versions of the actions have been deprecated since they internally use an old version of Node. Pinning the Ubuntu version prevents it from silently upgrading from 22.04 to 24.04, thus upgrading Python and breaking extra packages. It's possible to migrate at a more convenient time. --- .github/workflows/beta-image.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/beta-image.yml b/.github/workflows/beta-image.yml index a87f3357..6263a9a7 100644 --- a/.github/workflows/beta-image.yml +++ b/.github/workflows/beta-image.yml @@ -10,18 +10,18 @@ env: jobs: # define the job to build and publish docker images build-and-push-docker-images: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # steps to perform in the job steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 # set up Docker build action # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Get build date id: get_date @@ -30,7 +30,7 @@ jobs: # https://github.com/docker/metadata-action - name: Docker PHP meta id: meta_php - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ github.actor }}/linguacafe-webserver tags: | @@ -40,7 +40,7 @@ jobs: # https://github.com/docker/metadata-action - name: Docker Python meta id: meta_python - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ github.actor }}/linguacafe-python-service tags: | @@ -49,7 +49,7 @@ jobs: # https://github.com/docker/login-action#github-container-registry - name: Log in to Github Packages - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -58,7 +58,7 @@ jobs: # https://github.com/docker/build-push-action - name: Build and push PHP image to GitHub Container Registry id: docker_build_php - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: file: "./docker/PhpDockerfile" # extra platforms can be added here: @@ -76,7 +76,7 @@ jobs: # https://github.com/docker/build-push-action - name: Build and push Python image to GitHub Container Registry id: docker_build_python - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: file: "./docker/PythonDockerfile" platforms: | From 8823305e44bbd90e23684288ee7b11bbdd5f0d4d Mon Sep 17 00:00:00 2001 From: Sergio Laverde Date: Thu, 9 Jan 2025 17:01:26 -0500 Subject: [PATCH 2/3] feat: build images in parallel --- .github/workflows/beta-image.yml | 60 +++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/.github/workflows/beta-image.yml b/.github/workflows/beta-image.yml index 6263a9a7..cda015bc 100644 --- a/.github/workflows/beta-image.yml +++ b/.github/workflows/beta-image.yml @@ -8,9 +8,19 @@ env: # IMAGE_NAME: ${{ github.repository }} jobs: - # define the job to build and publish docker images - build-and-push-docker-images: + # + # capture time at the beginning to ensure consistent tagging + capture-date: runs-on: ubuntu-22.04 + steps: + - name: Get build date + id: get_date + run: echo "BUILD_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + + # build images in parallel for a speed increase + build-and-push-php-image: + runs-on: ubuntu-22.04 + needs: capture-date # steps to perform in the job steps: @@ -23,10 +33,6 @@ jobs: id: buildx uses: docker/setup-buildx-action@v3 - - name: Get build date - id: get_date - run: echo "BUILD_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - # https://github.com/docker/metadata-action - name: Docker PHP meta id: meta_php @@ -37,16 +43,6 @@ jobs: type=ref,event=branch type=ref,suffix=-${{ env.BUILD_DATE}},event=branch - # https://github.com/docker/metadata-action - - name: Docker Python meta - id: meta_python - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ github.actor }}/linguacafe-python-service - tags: | - type=ref,event=branch - type=ref,suffix=-${{ env.BUILD_DATE}},event=branch - # https://github.com/docker/login-action#github-container-registry - name: Log in to Github Packages uses: docker/login-action@v3 @@ -73,6 +69,38 @@ jobs: - name: PHP Image digest run: echo ${{ steps.docker_build_php.outputs.digest }} + build-and-push-python-image: + runs-on: ubuntu-22.04 + needs: capture-date + + steps: + - name: Check out code + uses: actions/checkout@v4 + + # set up Docker build action + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + # https://github.com/docker/metadata-action + - name: Docker Python meta + id: meta_python + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.actor }}/linguacafe-python-service + tags: | + type=ref,event=branch + type=ref,suffix=-${{ env.BUILD_DATE}},event=branch + + # https://github.com/docker/login-action#github-container-registry + - name: Log in to Github Packages + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GHCR_LINGUA_PAT }} + # https://github.com/docker/build-push-action - name: Build and push Python image to GitHub Container Registry id: docker_build_python From 0dc39bd4a85bed99d279b0bd904fbd7f056c554a Mon Sep 17 00:00:00 2001 From: Sergio Laverde Date: Thu, 9 Jan 2025 17:15:21 -0500 Subject: [PATCH 3/3] feat: cache layers for faster builds --- .github/workflows/beta-image.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/beta-image.yml b/.github/workflows/beta-image.yml index cda015bc..f58a5e97 100644 --- a/.github/workflows/beta-image.yml +++ b/.github/workflows/beta-image.yml @@ -57,6 +57,8 @@ jobs: uses: docker/build-push-action@v6 with: file: "./docker/PhpDockerfile" + cache-from: type=gha + cache-to: type=gha # extra platforms can be added here: platforms: | linux/amd64 @@ -107,6 +109,8 @@ jobs: uses: docker/build-push-action@v6 with: file: "./docker/PythonDockerfile" + cache-from: type=gha + cache-to: type=gha platforms: | linux/amd64 # Note: tags have to be all lower-case