Skip to content

Commit

Permalink
ci: 👷 add steps to create slimmed images for latest and tagged versio…
Browse files Browse the repository at this point in the history
…ns (#186)
  • Loading branch information
arrrgi authored Jan 28, 2024
1 parent 03c7bb5 commit 25f85fd
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,18 @@ jobs:
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
# Build and push Docker image with Buildx (don't push on PR)
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@94d76d3bc1409736cb5dc1ada9502bec3a72973c
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand All @@ -91,3 +92,26 @@ jobs:
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{
steps.build-and-push.outputs.digest }}

# Slim the container builds with Slim toolkit
- name: Slim the latest container build version
uses: kitabisa/docker-slim-action@v1
env:
DSLIM_HTTP_PROBE: false
with:
target: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${{ github.sha }}
tag: latest-slim

- name: Slim the semver container build version
if: ${{ github.event_name != 'pull_request' }}
uses: kitabisa/docker-slim-action@v1
env:
DSLIM_HTTP_PROBE: false
with:
target: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
tag: ${{ github.ref_name }}-slim

# Push the slimmed container builds to the registry except on PRs.
- name: Push the slimmed container builds to the registry
if: ${{ github.event_name != 'pull_request' }}
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} --all-tags

0 comments on commit 25f85fd

Please sign in to comment.