Skip to content

Commit b09547b

Browse files
authored
LGA-3218 - Add docker build cache during image build in the pipeline (#24)
* Add docker build cache during image build in the pipeline * Allow image to build early
1 parent 00a198a commit b09547b

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

.github/workflows/build.yml

+19-8
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,23 @@ jobs:
3636
with:
3737
mask-password: true
3838

39-
- name: Build and push a Docker image to the container repository
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
42+
- name: Docker meta
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ steps.login-ecr.outputs.registry }}/${{ inputs.ECR_REPOSITORY }}
47+
tags: |
48+
type=sha,format=long,prefix=,suffix=
49+
50+
- name: Build and push a Docker image to the container repository
4051
id: docker-build
41-
run: |
42-
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
43-
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
44-
env:
45-
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
46-
REPOSITORY: ${{ inputs.ECR_REPOSITORY }}
47-
IMAGE_TAG: ${{ github.sha }}
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: .
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max

.github/workflows/feature-branch.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
build-and-push:
2525
name: Build
2626
uses: ./.github/workflows/build.yml
27-
needs: static-analysis
2827
with:
2928
ECR_REGION: ${{vars.ECR_REGION}}
3029
ECR_REPOSITORY: ${{vars.ECR_REPOSITORY}}
@@ -61,7 +60,7 @@ jobs:
6160
deploy-uat:
6261
name: UAT
6362
uses: ./.github/workflows/deploy.yml
64-
needs: [build-and-push, test]
63+
needs: [build-and-push, static-analysis, test]
6564
with:
6665
environment: uat
6766
ECR_REGION: ${{vars.ECR_REGION}}

0 commit comments

Comments
 (0)