From c99c42dd79f82f66c358ca24cea6b326f99d574e Mon Sep 17 00:00:00 2001 From: greenhat616 Date: Sun, 27 Aug 2023 17:48:54 +0800 Subject: [PATCH] fix: alpine dynamic link issue --- .github/workflows/docker_push_latest.yml | 2 +- manifest/docker/Dockerfile | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker_push_latest.yml b/.github/workflows/docker_push_latest.yml index 0d7d9df..38b79c0 100644 --- a/.github/workflows/docker_push_latest.yml +++ b/.github/workflows/docker_push_latest.yml @@ -26,7 +26,7 @@ jobs: with: go-version: '1.21' - name: Build - run: mkdir -p ./temp && go build -o ./temp/linux_amd64/hitokoto_reviewer ./main.go + run: mkdir -p ./temp && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w --extldflags "-static -fpic"' -o ./temp/linux_amd64/hitokoto_reviewer main.go - name: Build and push uses: docker/build-push-action@v4 diff --git a/manifest/docker/Dockerfile b/manifest/docker/Dockerfile index 414d2a1..96670f4 100644 --- a/manifest/docker/Dockerfile +++ b/manifest/docker/Dockerfile @@ -3,7 +3,6 @@ FROM alpine:3.18 ############################################################################### # INSTALLATION ############################################################################### - ENV WORKDIR /app ADD resource $WORKDIR/ ADD ./temp/linux_amd64/hitokoto_reviewer $WORKDIR/hitokoto_reviewer @@ -13,4 +12,4 @@ RUN chmod +x $WORKDIR/hitokoto_reviewer # START ############################################################################### WORKDIR $WORKDIR -ENTRYPOINT ["sh"] +CMD ["./hitokoto_reviewer"]