Skip to content

Commit

Permalink
Docker caching in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamVyborny committed May 7, 2024
1 parent dcfbf76 commit 57ca6ff
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,34 @@ jobs:
app_image_tag: ${{ steps.tag.outputs.app_image_tag }}
is_semantic_tag: ${{ steps.tag.outputs.is_semantic_tag }}
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Print Docker version
- name: Check out the repo
uses: actions/checkout@v4

- name: Print Docker version
run: docker -v
-
name: Docker login
if: env.DOCKERHUB_TOKEN
run: docker login --username "$DOCKERHUB_USER" --password "$DOCKERHUB_TOKEN"
-
name: Build image
run: docker build -t $APP_IMAGE .
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: docker-${{ hashFiles('Dockerfile') }}-${{ github.sha }}
restore-keys: |
docker-${{ hashFiles('Dockerfile') }}
-
name: Build and push Docker image with cache
run: |
docker buildx build \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache \
--output=type=docker \
--tag $APP_IMAGE .
-
name: Set image tag
id: tag
Expand All @@ -58,13 +73,13 @@ jobs:
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ steps.tag.outputs.app_image_tag }}
push_latest: ${{ steps.tag.outputs.is_semantic_tag }}
source_image: ${{ env.APP_IMAGE}}
source_image: ${{ env.APP_IMAGE }}

python-tests:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build image
working-directory: ./python-sync-actions
Expand All @@ -85,7 +100,7 @@ jobs:
steps:
-
name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v4
-
name: Pull image from ECR
uses: keboola/action-pull-from-ecr@master
Expand All @@ -107,7 +122,7 @@ jobs:
steps:
-
name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v4
-
name: Pull image from ECR
uses: keboola/action-pull-from-ecr@master
Expand Down

0 comments on commit 57ca6ff

Please sign in to comment.