fix: build error

This commit is contained in:
Sh1n3zZ 2025-02-12 16:47:37 +08:00
parent 6fb6b6a229
commit bd7987bb64
No known key found for this signature in database
GPG Key ID: 696702CF723B0452
2 changed files with 17 additions and 9 deletions

View File

@ -2,31 +2,37 @@ name: Docker Image CI
on:
push:
branches: [ main ]
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: "arm64,amd64"
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Build and push Docker images
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: programzmh/chatnio:latest
cache-from: type=registry,ref=programzmh/chatnio:buildcache
cache-to: type=registry,ref=programzmh/chatnio:buildcache,mode=max

View File

@ -2,14 +2,16 @@
# License: Apache-2.0
# Description: Dockerfile for chatnio
FROM golang:1.20-alpine AS backend
FROM --platform=$BUILDPLATFORM golang:1.20-alpine AS backend
WORKDIR /backend
COPY . .
# Set go proxy to https://goproxy.cn (open for vps in China Mainland)
# RUN go env -w GOPROXY=https://goproxy.cn,direct
ENV GOOS=linux GO111MODULE=on CGO_ENABLED=1
ARG TARGETARCH
ARG TARGETOS
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on CGO_ENABLED=1
# Install dependencies for cgo
RUN apk add --no-cache gcc musl-dev