From 93e960ccd9efabb10bbac5a2543d3c63821543b2 Mon Sep 17 00:00:00 2001 From: wood chen Date: Wed, 9 Oct 2024 13:08:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Docker=20=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=EF=BC=8C=E6=B7=BB=E5=8A=A0=20Go=20=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=88=9D=E5=A7=8B=E5=8C=96=E5=8F=8A=E4=BA=8C=E8=BF=9B?= =?UTF-8?q?=E5=88=B6=E6=9E=84=E5=BB=BA=E6=AD=A5=E9=AA=A4=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20Dockerfile=20=E4=B8=AD=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yml | 18 +++++++++++++----- Dockerfile | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bb1dacb..b7c3a0d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -27,6 +27,19 @@ jobs: with: go-version: ${{ matrix.go-version }} + - name: Initialize Go module if needed + working-directory: ./code + run: | + if [ ! -f go.mod ]; then + go mod init github.com/${{ github.repository }} + go mod tidy + fi + + - name: Build Go binary + working-directory: ./code + run: | + CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} go build -ldflags '-w -s' -o ../feishu_chatgpt + - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -39,10 +52,6 @@ jobs: username: woodchen password: ${{ secrets.ACCESS_TOKEN }} - - name: Build Go binary - run: | - CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} go build -ldflags '-w -s' -o feishu_chatgpt - - name: Prepare Docker metadata id: meta uses: docker/metadata-action@v4 @@ -62,4 +71,3 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - diff --git a/Dockerfile b/Dockerfile index 944912d..98db6d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,6 @@ WORKDIR /app RUN apk add --no-cache bash COPY feishu_chatgpt /app -COPY role_list.yaml /app +COPY code/role_list.yaml /app EXPOSE 9000 ENTRYPOINT ["/app/feishu_chatgpt"]