fix(build): Enable architecture-aware backend builds for multi-platform support

Signed-off-by: Nimbus318 <136771156+Nimbus318@users.noreply.github.com>
main
Nimbus318 3 months ago committed by 霓漠Nimbus
parent 6b9e831b2b
commit 0b59548079

@ -2,11 +2,13 @@ FROM golang:1.23.1 AS builder
WORKDIR /src
ARG TARGETARCH
COPY . .
RUN apt-get update && apt-get install -y --no-install-recommends protobuf-compiler
RUN make build
RUN make build TARGET_ARCH=${TARGETARCH}
FROM debian:stable-slim

@ -3,6 +3,7 @@ CMD_PATH ?= ./cmd/
BUILD_PATH ?= ./build/
VERSION ?= $(shell git describe --tags --always)
DIRS = $(shell ls $(CMD_PATH))
TARGET_ARCH ?= amd64
# 1. Install Go dependencies
.PHONY: install-deps
@ -37,10 +38,11 @@ tidy-mod:
# 4. Build-related commands
.PHONY: build-linux
build-linux:
@ for dir in $(DIRS); \
@echo "Building for GOOS=linux GOARCH=$(TARGET_ARCH)" # TARGET_ARCH 会从 make 命令传入
@for dir in $(DIRS); \
do \
GO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BUILD_PATH)$$dir ${CMD_PATH}$$dir; \
echo "Built $$dir for Linux"; \
CGO_ENABLED=0 GOOS=linux GOARCH=$(TARGET_ARCH) go build -o $(BUILD_PATH)$$dir ${CMD_PATH}$$dir; \
echo "Built $$dir for Linux/$(TARGET_ARCH)"; \
done
.PHONY: build-local

Loading…
Cancel
Save