To optimize Docker image size.

This commit is contained in:
yoan 2024-08-30 22:25:01 +08:00
parent 51d5c24ef3
commit 48bcd32268
3 changed files with 18 additions and 7 deletions

View File

@ -2,13 +2,22 @@ name: Docker Image CI
on:
push:
branches: ["main"]
tags:
- "*"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.22.5"
- name: Build certimate
run: go build -o certimate
- name: Checkout code
uses: actions/checkout@v4
@ -26,6 +35,10 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract Git tag
id: get_tag
run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
@ -33,4 +46,4 @@ jobs:
file: ./Dockerfile_build
platforms: linux/amd64,linux/arm64
push: true
tags: registry.cn-shanghai.aliyuncs.com/usual2970/certimate:latest
tags: registry.cn-shanghai.aliyuncs.com/usual2970/certimate:${{ env.tag }}

2
.gitignore vendored
View File

@ -2,7 +2,7 @@ __debug_bin*
vendor
pb_data
main
./certimate
certimate
build
/docker/data

View File

@ -1,10 +1,8 @@
FROM golang:1.22-alpine
FROM alpine:3.20
WORKDIR /app
COPY ../. /app/
RUN go build -o certimate
COPY certimate /app/certimate
ENTRYPOINT ["./certimate", "serve", "--http", "0.0.0.0:8090"]