Skip to content

Commit

Permalink
build: create slim variants of container images (#3218)
Browse files Browse the repository at this point in the history
We want to test slim(med) images, for improved security and container
image size.
See https://github.com/slimtoolkit/slim for details.
  • Loading branch information
kyubisation authored Nov 20, 2024
1 parent b1e75ee commit 126a4ab
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/continuous-integration-secure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ jobs:
docker push $IMAGE_REPO_PREVIEW:pr$PR_NUMBER
env:
DOCKER_BUILDKIT: 1
- name: Build slim image
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_PREVIEW }}:pr${{ env.PR_NUMBER }}'
tag: '${{ env.IMAGE_REPO_PREVIEW }}:pr${{ env.PR_NUMBER }}-slim'
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
run: |
docker push $IMAGE_REPO_PREVIEW:pr$PR_NUMBER-slim
docker image list
- name: "Add 'preview-available' label"
# This label is used for filtering deployments in ArgoCD
Expand Down Expand Up @@ -181,6 +192,18 @@ jobs:
docker push $IMAGE_REPO_VISUAL_REGRESSION:pr$PR_NUMBER
env:
DOCKER_BUILDKIT: 1
- name: Build slim image
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_VISUAL_REGRESSION }}:pr${{ env.PR_NUMBER }}'
tag: '${{ env.IMAGE_REPO_VISUAL_REGRESSION }}:pr${{ env.PR_NUMBER }}-slim'
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
run: |
docker push $IMAGE_REPO_VISUAL_REGRESSION:pr{{ env.PR_NUMBER }}-slim
docker image list
- name: Apply labels
if: steps.screenshot-check.outputs.result == 'changed' || steps.screenshot-check.outputs.result == 'empty'
run: |
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,14 @@ jobs:
docker push $IMAGE_REPO_VISUAL_REGRESSION:baseline
env:
DOCKER_BUILDKIT: 1
- name: Build slim image
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_VISUAL_REGRESSION }}:baseline'
tag: '${{ env.IMAGE_REPO_VISUAL_REGRESSION }}:baseline-slim'
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
run: |
docker push $IMAGE_REPO_VISUAL_REGRESSION:baseline-slim
docker image list
35 changes: 35 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,47 @@ jobs:
env:
DOCKER_BUILDKIT: 1
VERSION: ${{ steps.release.outputs.version }}
- name: Build slim image with version
if: ${{ steps.release.outputs.release_created }}
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:${{ steps.release.outputs.version }}'
tag: '${{ env.IMAGE_REPO_STORYBOOK }}:${{ steps.release.outputs.version }}-slim'
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Build slim image with latest
if: ${{ steps.release.outputs.release_created }}
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:latest'
tag: '${{ env.IMAGE_REPO_STORYBOOK }}:latest-slim'
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
if: ${{ steps.release.outputs.release_created }}
run: |
docker push $IMAGE_REPO_STORYBOOK:$VERSION-slim
docker push $IMAGE_REPO_STORYBOOK:latest-slim
docker image list
env:
VERSION: ${{ steps.release.outputs.version }}
- name: 'Container: Build and publish dev image'
run: |
docker build --tag $IMAGE_REPO_STORYBOOK:dev .
docker push $IMAGE_REPO_STORYBOOK:dev
env:
DOCKER_BUILDKIT: 1
- name: Build slim image with dev
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:dev'
tag: '${{ env.IMAGE_REPO_STORYBOOK }}:dev-slim'
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
run: |
docker push $IMAGE_REPO_STORYBOOK:dev-slim
docker image list
- name: Cherry-pick CHANGELOG.md into ${{ github.event.repository.default_branch }}
if: ${{ steps.release.outputs.release_created && github.ref_name != 'main' }}
Expand Down

0 comments on commit 126a4ab

Please sign in to comment.