From 646e3d0553df1123bd1633448d1d615f9ef9d7ec Mon Sep 17 00:00:00 2001 From: Lukas Spirig Date: Thu, 30 Jan 2025 10:03:43 +0100 Subject: [PATCH] build: use mint to minify container images --- .github/actions/setup-mint/action.yml | 19 +++++++++++++++++++ .github/workflows/continuous-integration.yml | 16 ++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 .github/actions/setup-mint/action.yml diff --git a/.github/actions/setup-mint/action.yml b/.github/actions/setup-mint/action.yml new file mode 100644 index 00000000..4a6bea03 --- /dev/null +++ b/.github/actions/setup-mint/action.yml @@ -0,0 +1,19 @@ +name: mint +description: Setup https://github.com/mintoolkit/mint + +runs: + using: composite + steps: + - name: Setup mint + run: | + mkdir -p "$HOME/.local/bin" + cd "$HOME/.local/bin" + + # Get the current released tag_name + VER=$(curl -sL https://api.github.com/repos/mintoolkit/mint/releases \ + | grep tag_name | head -n1 | cut -d'"' -f4) + curl -L -o mint.tar.gz "https://github.com/mintoolkit/mint/releases/download/${VER}/dist_linux.tar.gz" + tar -xvf mint.tar.gz --strip-components 1 + + echo "Installed mint:${VER}" + shell: bash diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index bcae3e32..520df140 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -59,11 +59,15 @@ jobs: with: name: showcase path: dist/ - - name: 'Container: Login to GitHub Container Repository' - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username ${{ github.actor }} --password-stdin - - name: 'Container: Build image' - run: docker build -t $IMAGE_REPO:latest . + - uses: ./.github/actions/setup-mint + - name: 'Container: Build and push image' + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username ${{ github.actor }} --password-stdin + docker build -t $IMAGE_REPO:latest-fat . + mint slim \ + --target $IMAGE_REPO:latest-fat \ + --tag $IMAGE_REPO:latest \ + --preserve-path /usr/share/nginx/html + docker push $IMAGE_REPO:latest env: DOCKER_BUILDKIT: 1 - - name: 'Container: Publish image' - run: docker push $IMAGE_REPO:latest