Skip to content

Commit

Permalink
build: use custom action for docker slim
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation committed Dec 16, 2024
1 parent 9fe9ae8 commit f6c7708
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 18 deletions.
24 changes: 24 additions & 0 deletions .github/actions/docker-slim/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Docker Slim
description: Create slim versions of an existing container images

inputs:
target:
description: The target image
required: true
tag:
description: The target image
required: true
runs:
using: composite
steps:
- name: Setup docker slim
run: |
mkdir /tmp/ds
cd /tmp/ds
curl -L -o ds.tar.gz https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux.tar.gz
tar -xvf ds.tar.gz --directory
echo "/tmp/ds/dist_linux" >> $GITHUB_PATH
shell: bash
- name: Run docker slim
run: slim build --target ${{ inputs.target }} --tag ${{ inputs.tag }} --preserve-path /usr/share/nginx/html
shell: bash
8 changes: 2 additions & 6 deletions .github/workflows/continuous-integration-secure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ jobs:
env:
DOCKER_BUILDKIT: 1
- name: Build slim image
uses: kitabisa/docker-slim-action@v1
uses: ./.github/actions/docker-slim
with:
target: '${{ env.IMAGE_REPO_PREVIEW }}:pr${{ env.PR_NUMBER }}'
tag: '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
Expand Down Expand Up @@ -193,12 +191,10 @@ jobs:
env:
DOCKER_BUILDKIT: 1
- name: Build slim image
uses: kitabisa/docker-slim-action@v1
uses: ./.github/actions/docker-slim
with:
target: '${{ env.IMAGE_REPO_VISUAL_REGRESSION }}:pr${{ env.PR_NUMBER }}'
tag: '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$PR_NUMBER-slim
Expand Down
26 changes: 23 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ env:
IMAGE_REPO_VISUAL_REGRESSION: ghcr.io/${{ github.repository }}/visual-regression

jobs:
slim-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: yarn
- run: |
mkdir -p dist/storybook
echo "test" > dist/storybook/index.html
- name: Build and push visual regression baseline
run: |
docker build --tag simple-test:test .
env:
DOCKER_BUILDKIT: 1
- name: Build slim image
uses: ./.github/actions/docker-slim
with:
target: 'simple-test:test'
tag: test-slim

lint:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -160,12 +182,10 @@ jobs:
env:
DOCKER_BUILDKIT: 1
- name: Build slim image
uses: kitabisa/docker-slim-action@v1
uses: ./.github/actions/docker-slim
with:
target: '${{ env.IMAGE_REPO_VISUAL_REGRESSION }}:baseline'
tag: baseline-slim
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
run: |
docker push $IMAGE_REPO_VISUAL_REGRESSION:baseline-slim
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,16 @@ jobs:
VERSION: ${{ steps.release.outputs.version }}
- name: Build slim image with version
if: ${{ steps.release.outputs.release_created }}
uses: kitabisa/docker-slim-action@v1
uses: ./.github/actions/docker-slim
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:${{ steps.release.outputs.version }}'
tag: '${{ 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
uses: ./.github/actions/docker-slim
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:latest'
tag: latest-slim
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
if: ${{ steps.release.outputs.release_created }}
run: |
Expand All @@ -125,12 +121,10 @@ jobs:
env:
DOCKER_BUILDKIT: 1
- name: Build slim image with dev
uses: kitabisa/docker-slim-action@v1
uses: ./.github/actions/docker-slim
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:dev'
tag: dev-slim
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
run: |
docker push $IMAGE_REPO_STORYBOOK:dev-slim
Expand Down

0 comments on commit f6c7708

Please sign in to comment.