refactor: streamline docker image build and push process

This commit is contained in:
wood chen 2024-10-22 19:15:50 +08:00
parent f12eafb25a
commit 4c674c8a9c
2 changed files with 4 additions and 42 deletions

View File

@ -1,5 +1,4 @@
name: Build and Push Docker Image name: Build docker images
on: on:
push: push:
paths-ignore: paths-ignore:
@ -17,27 +16,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libvips-dev
- name: Build for amd64
run: |
GOOS=linux GOARCH=amd64 go build -o builds/webp-server-linux-amd64 .
- name: Build for arm64
run: |
GOOS=linux GOARCH=arm64 go build -o builds/webp-server-linux-arm64 .
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -50,12 +31,11 @@ jobs:
username: woodchen username: woodchen
password: ${{ secrets.ACCESS_TOKEN }} password: ${{ secrets.ACCESS_TOKEN }}
- name: Build and push Docker image - name: Build and push
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
file: Dockerfile.multi file: Dockerfile
push: true push: true
tags: woodchen/${{ env.IMAGE_NAME }}:latest tags: woodchen/${{ env.IMAGE_NAME }}:latest
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64

View File

@ -1,18 +0,0 @@
FROM debian:bookworm-slim
RUN apt-get update && \
apt-get install --no-install-recommends -y libvips ca-certificates libjemalloc2 libtcmalloc-minimal4 && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/archives/*
WORKDIR /usr/bin
COPY builds/webp-server-linux-amd64 webp-server-linux-amd64
COPY builds/webp-server-linux-arm64 webp-server-linux-arm64
COPY config.json /etc/config.json
RUN chmod +x webp-server-linux-amd64 webp-server-linux-arm64
WORKDIR /opt
VOLUME /opt/exhaust
CMD ["/bin/sh", "-c", "if [ \"$(uname -m)\" = \"aarch64\" ]; then /usr/bin/webp-server-linux-arm64 --config /etc/config.json; else /usr/bin/webp-server-linux-amd64 --config /etc/config.json; fi"]