Skip to content

Commit

Permalink
Update Api-Docker-Image-CI.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
kaer98 authored Oct 23, 2024
1 parent c9bfcc9 commit ae03c90
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions .github/workflows/Api-Docker-Image-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,34 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image

# Cache Docker layers
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ hashFiles('**/*.dockerfile') }}
restore-keys: |
${{ runner.os }}-docker-
# Set up Docker Buildx (for advanced caching features)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Build and push the Docker image with cache
- name: Build and push the Docker image
run: |
echo ${{ secrets.REGISTRY_PASSWORD }} | docker login registry.jazper.dk --username ${{ secrets.REGISTRY_USERNAME }} --password-stdin
docker build -f ./Api.Dockerfile -t registry.jazper.dk/notam-management-api:latest .
docker push registry.jazper.dk/notam-management-api:latest
docker buildx build \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max \
-f ./Api.Dockerfile \
-t registry.jazper.dk/notam-management-api:latest \
--push .
# Move new cache to the original location after build
- name: Update Docker cache
if: success()
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 comments on commit ae03c90

Please sign in to comment.