This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# ================================
|
||||
# 阶段 1: 构建阶段
|
||||
# ================================
|
||||
FROM golang:1.23.4-alpine AS builder
|
||||
FROM golang:1.25.6-alpine AS builder
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /build
|
||||
@@ -14,7 +14,6 @@ COPY go.mod go.sum ./
|
||||
|
||||
# 使用国内 Go 代理加速依赖下载
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOTOOLCHAIN=auto
|
||||
|
||||
RUN go mod download
|
||||
|
||||
@@ -22,13 +21,13 @@ RUN go mod download
|
||||
COPY . .
|
||||
|
||||
# 编译 API 服务(静态链接)
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOTOOLCHAIN=auto go build \
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags="-w -s" \
|
||||
-o /build/api \
|
||||
cmd/api/main.go
|
||||
|
||||
# 下载 golang-migrate 工具
|
||||
RUN GOTOOLCHAIN=auto go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
|
||||
RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
|
||||
|
||||
# ================================
|
||||
# 阶段 2: 运行阶段
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# ================================
|
||||
# 阶段 1: 构建阶段
|
||||
# ================================
|
||||
FROM golang:1.23.4-alpine AS builder
|
||||
FROM golang:1.25.6-alpine AS builder
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /build
|
||||
@@ -14,7 +14,6 @@ COPY go.mod go.sum ./
|
||||
|
||||
# 使用国内 Go 代理加速依赖下载
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOTOOLCHAIN=auto
|
||||
|
||||
RUN go mod download
|
||||
|
||||
@@ -22,7 +21,7 @@ RUN go mod download
|
||||
COPY . .
|
||||
|
||||
# 编译 Worker 服务(静态链接)
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOTOOLCHAIN=auto go build \
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags="-w -s" \
|
||||
-o /build/worker \
|
||||
cmd/worker/main.go
|
||||
|
||||
Reference in New Issue
Block a user