diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 9ba9be1e..69188137 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index 8ef500b1..029054a0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ __debug_bin* vendor pb_data main -./certimate +certimate build /docker/data diff --git a/Dockerfile_build b/Dockerfile_build index 63fae28c..cc5e8e87 100644 --- a/Dockerfile_build +++ b/Dockerfile_build @@ -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"] \ No newline at end of file