diff --git a/.github/actions/docker-slim/action.yml b/.github/actions/docker-slim/action.yml new file mode 100644 index 0000000000..34e982c709 --- /dev/null +++ b/.github/actions/docker-slim/action.yml @@ -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 diff --git a/.github/workflows/continuous-integration-secure.yml b/.github/workflows/continuous-integration-secure.yml index e4d1815ae3..f8dfe17655 100644 --- a/.github/workflows/continuous-integration-secure.yml +++ b/.github/workflows/continuous-integration-secure.yml @@ -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 @@ -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 diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ee60ae9c38..cc2203f697 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -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: @@ -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 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 27706cada5..49d22c10c3 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -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: | @@ -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