mirror of
https://github.com/woodchen-ink/Oapi-Feishu.git
synced 2025-07-18 05:42:08 +08:00
优化 Docker 工作流以支持多平台构建与推送,更新 Go 版本至 1.23
This commit is contained in:
parent
93e960ccd9
commit
8e7b885957
90
.github/workflows/docker.yml
vendored
90
.github/workflows/docker.yml
vendored
@ -13,61 +13,53 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go-version: [1.23.x]
|
|
||||||
platform: [linux/amd64, linux/arm64]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: '1.23' # 使用你项目需要的 Go 版本
|
||||||
|
|
||||||
- name: Initialize Go module if needed
|
- name: Build for amd64
|
||||||
working-directory: ./code
|
run: |
|
||||||
run: |
|
cd code
|
||||||
if [ ! -f go.mod ]; then
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-w -s' -o ../feishu_chatgpt-amd64
|
||||||
go mod init github.com/${{ github.repository }}
|
|
||||||
go mod tidy
|
- name: Build for arm64
|
||||||
fi
|
run: |
|
||||||
|
cd code
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags '-w -s' -o ../feishu_chatgpt-arm64
|
||||||
|
|
||||||
- name: Build Go binary
|
- name: Set up QEMU
|
||||||
working-directory: ./code
|
uses: docker/setup-qemu-action@v3
|
||||||
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
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Login to Docker Hub
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: woodchen
|
||||||
|
password: ${{ secrets.ACCESS_TOKEN }}
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Build and push Docker image
|
||||||
uses: docker/login-action@v2
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
username: woodchen
|
context: .
|
||||||
password: ${{ secrets.ACCESS_TOKEN }}
|
file: Dockerfile.multi
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
woodchen/${{ env.IMAGE_NAME }}:latest
|
||||||
|
woodchen/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||||
|
|
||||||
- name: Prepare Docker metadata
|
- name: Update Docker Hub description
|
||||||
id: meta
|
uses: peter-evans/dockerhub-description@v4
|
||||||
uses: docker/metadata-action@v4
|
with:
|
||||||
with:
|
username: woodchen
|
||||||
images: woodchen/${{ env.IMAGE_NAME }}
|
password: ${{ secrets.ACCESS_TOKEN }}
|
||||||
tags: |
|
repository: woodchen/${{ env.IMAGE_NAME }}
|
||||||
type=ref,event=branch
|
short-description: ${{ github.event.repository.description }}
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
uses: docker/build-push-action@v4
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: ${{ matrix.platform }}
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
18
Dockerfile.multi
Normal file
18
Dockerfile.multi
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
FROM --platform=$TARGETPLATFORM alpine:latest
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache bash
|
||||||
|
|
||||||
|
COPY feishu_chatgpt-* /app/
|
||||||
|
COPY code/role_list.yaml /app/
|
||||||
|
|
||||||
|
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
|
||||||
|
mv /app/feishu_chatgpt-amd64 /app/feishu_chatgpt; \
|
||||||
|
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
||||||
|
mv /app/feishu_chatgpt-arm64 /app/feishu_chatgpt; \
|
||||||
|
fi && \
|
||||||
|
chmod +x /app/feishu_chatgpt
|
||||||
|
|
||||||
|
EXPOSE 9000
|
||||||
|
ENTRYPOINT ["/app/feishu_chatgpt"]
|
Loading…
x
Reference in New Issue
Block a user