feat: Update Docker image build process to improve tagging and slim image handling for amd64 and arm64

This commit is contained in:
2025-03-27 21:56:23 +07:00
parent ac06b8decb
commit f69ee755be

View File

@@ -58,23 +58,30 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build the Docker image first without pushing
- name: Build Docker image for amd64
uses: docker/build-push-action@v6
with:
context: .
load: true
push: false
platforms: linux/amd64
tags: ghcr.io/coder-vippro/chatgpt-discord-bot:latest-amd64
load: true
- name: Slim Docker image for amd64
uses: docker-slim/docker-slim-action@v1
# Apply Docker Slim to reduce image size
- name: Slim Docker image
uses: kitabisa/docker-slim-action@v1
env:
DSLIM_HTTP_PROBE: false
with:
target: ghcr.io/coder-vippro/chatgpt-discord-bot:latest-amd64
tag: ghcr.io/coder-vippro/chatgpt-discord-bot:slim-amd64
tag: "latest-amd64-slim"
- name: Push slimmed Docker image for amd64
# Push the slimmed image to registry
- name: Push Docker image to registry
run: |
docker push ghcr.io/coder-vippro/chatgpt-discord-bot:slim-amd64
docker tag ghcr.io/coder-vippro/chatgpt-discord-bot:latest-amd64-slim ghcr.io/coder-vippro/chatgpt-discord-bot:latest-amd64
docker push ghcr.io/coder-vippro/chatgpt-discord-bot:latest-amd64
build-arm64:
runs-on: ubuntu-24.04-arm
@@ -94,23 +101,30 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build the Docker image first without pushing
- name: Build Docker image for arm64
uses: docker/build-push-action@v6
with:
context: .
load: true
push: false
platforms: linux/arm64
tags: ghcr.io/coder-vippro/chatgpt-discord-bot:latest-arm64
load: true
- name: Slim Docker image for arm64
uses: docker-slim/docker-slim-action@v1
# Apply Docker Slim to reduce image size
- name: Slim Docker image
uses: kitabisa/docker-slim-action@v1
env:
DSLIM_HTTP_PROBE: false
with:
target: ghcr.io/coder-vippro/chatgpt-discord-bot:latest-arm64
tag: ghcr.io/coder-vippro/chatgpt-discord-bot:slim-arm64
tag: "latest-arm64-slim"
- name: Push slimmed Docker image for arm64
# Push the slimmed image to registry
- name: Push Docker image to registry
run: |
docker push ghcr.io/coder-vippro/chatgpt-discord-bot:slim-arm64
docker tag ghcr.io/coder-vippro/chatgpt-discord-bot:latest-arm64-slim ghcr.io/coder-vippro/chatgpt-discord-bot:latest-arm64
docker push ghcr.io/coder-vippro/chatgpt-discord-bot:latest-arm64
merge-manifest:
runs-on: ubuntu-latest
@@ -126,8 +140,8 @@ jobs:
- name: Create and push multi-arch manifest
run: |
docker buildx imagetools create -t ghcr.io/coder-vippro/chatgpt-discord-bot:latest \
ghcr.io/coder-vippro/chatgpt-discord-bot:slim-amd64 \
ghcr.io/coder-vippro/chatgpt-discord-bot:slim-arm64
ghcr.io/coder-vippro/chatgpt-discord-bot:latest-amd64 \
ghcr.io/coder-vippro/chatgpt-discord-bot:latest-arm64
deploy-notification:
runs-on: ubuntu-latest
@@ -140,7 +154,7 @@ jobs:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "✅ New deployment successful!"
description: |
Image: ghcr.io/coder-vippro/chatgpt-discord-bot:latest
Image: ${{ needs.build-and-push.outputs.image }}:${{ needs.build-and-push.outputs.version }}
Commit: ${{ github.sha }}
Repository: ${{ github.repository }}
color: 0x00ff00