Skip to content

Commit 407f405

Browse files
committed
fix: update CI workflow for consistency and clarity
- Changed the Dockerfile stage name from 'as' to 'AS' for consistency. - Removed conditional checks for pull requests in the GitHub Actions workflow to ensure builds run on all events. - Simplified the Docker build process by setting the push option to true and ensuring both AMD64 and ARM64 digests are used in the manifest creation step.
1 parent db83393 commit 407f405

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

.github/workflows/docker-build.yml

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
IMAGE_NAME: ${{ github.repository }}
1313

1414
jobs:
15-
# Job for AMD64 architecture - runs on all events
15+
# Job for AMD64 architecture
1616
build-amd64:
1717
runs-on: ubuntu-latest
1818
permissions:
@@ -27,7 +27,6 @@ jobs:
2727
id: buildx
2828

2929
- name: Log in to the Container registry
30-
if: github.event_name != 'pull_request'
3130
uses: docker/login-action@v3
3231
with:
3332
registry: ${{ env.REGISTRY }}
@@ -51,40 +50,36 @@ jobs:
5150
uses: docker/build-push-action@v5
5251
with:
5352
context: .
54-
push: ${{ github.event_name != 'pull_request' }}
53+
push: true
5554
tags: ${{ steps.meta.outputs.tags }}-amd64
5655
labels: ${{ steps.meta.outputs.labels }}
5756
platforms: linux/amd64
5857
cache-from: type=gha
5958
cache-to: type=gha,mode=max
6059
builder: ${{ steps.buildx.outputs.name }}
61-
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
60+
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
6261

6362
- name: Export AMD64 digest
64-
if: github.event_name != 'pull_request'
6563
run: |
6664
mkdir -p /tmp/digests
6765
digest="${{ steps.build.outputs.digest }}"
6866
touch "/tmp/digests/${digest#sha256:}"
6967
echo "AMD64_DIGEST=${digest}" >> $GITHUB_ENV
7068
7169
- name: Upload AMD64 digest
72-
if: github.event_name != 'pull_request'
7370
uses: actions/upload-artifact@v4
7471
with:
7572
name: amd64-digest
7673
path: /tmp/digests/*
7774
if-no-files-found: error
7875
retention-days: 1
7976

80-
# Job for ARM64 architecture - only runs on main branch
77+
# Job for ARM64 architecture - runs on all events
8178
build-arm64:
8279
runs-on: ubuntu-latest
8380
permissions:
8481
contents: read
8582
packages: write
86-
# Only run this job for pushes to main, not for PRs
87-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
8883
steps:
8984
- name: Checkout repository
9085
uses: actions/checkout@v4
@@ -107,6 +102,7 @@ jobs:
107102
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
108103
tags: |
109104
type=ref,event=branch
105+
type=ref,event=pr
110106
type=semver,pattern={{version}}
111107
type=semver,pattern={{major}}.{{minor}}
112108
type=sha,format=long
@@ -144,9 +140,6 @@ jobs:
144140
create-manifest:
145141
runs-on: ubuntu-latest
146142
needs: [build-amd64, build-arm64]
147-
# This job only runs if at least build-amd64 completed successfully
148-
# build-arm64 might be skipped for PRs, so we don't require it
149-
if: github.event_name != 'pull_request' && always() && needs.build-amd64.result == 'success'
150143
permissions:
151144
contents: read
152145
packages: write
@@ -158,8 +151,6 @@ jobs:
158151
path: /tmp/digests/amd64
159152

160153
- name: Download ARM64 digest
161-
# Only try to download ARM64 digest if the job ran
162-
if: needs.build-arm64.result == 'success'
163154
uses: actions/download-artifact@v4
164155
with:
165156
name: arm64-digest
@@ -182,6 +173,7 @@ jobs:
182173
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
183174
tags: |
184175
type=ref,event=branch
176+
type=ref,event=pr
185177
type=semver,pattern={{version}}
186178
type=semver,pattern={{major}}.{{minor}}
187179
type=sha,format=long
@@ -191,22 +183,14 @@ jobs:
191183
# Get the first tag from meta outputs
192184
FIRST_TAG=$(echo "${{ steps.meta.outputs.tags }}" | cut -d, -f1)
193185
194-
# If ARM64 build was skipped, only use AMD64 digest
195-
if [ "${{ needs.build-arm64.result }}" != "success" ]; then
196-
AMD64_DIGEST=$(cat /tmp/digests/amd64/*)
197-
docker buildx imagetools create \
198-
--tag ${FIRST_TAG} \
199-
${AMD64_DIGEST}
200-
else
201-
# Otherwise use both digests
202-
AMD64_DIGEST=$(cat /tmp/digests/amd64/*)
203-
ARM64_DIGEST=$(cat /tmp/digests/arm64/*)
204-
docker buildx imagetools create \
205-
--tag ${FIRST_TAG} \
206-
${AMD64_DIGEST} ${ARM64_DIGEST}
207-
fi
186+
# Use both digests
187+
AMD64_DIGEST=$(cat /tmp/digests/amd64/*)
188+
ARM64_DIGEST=$(cat /tmp/digests/arm64/*)
189+
docker buildx imagetools create \
190+
--tag ${FIRST_TAG} \
191+
${AMD64_DIGEST} ${ARM64_DIGEST}
208192
209193
- name: Inspect image
210194
run: |
211195
FIRST_TAG=$(echo "${{ steps.meta.outputs.tags }}" | cut -d, -f1)
212-
docker buildx imagetools inspect ${FIRST_TAG}
196+
docker buildx imagetools inspect ${FIRST_TAG}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Frontend build stage
2-
FROM node:20-slim as frontend-builder
2+
FROM node:20-slim AS frontend-builder
33
WORKDIR /app/frontend
44

55
# Copy package files first to leverage layer caching
@@ -42,4 +42,4 @@ ENV PYTHONUNBUFFERED=1
4242
EXPOSE 8000
4343

4444
# Run the application
45-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
45+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)