Dockerfile
This commit is contained in:
10
Dockerfile
10
Dockerfile
@@ -1,5 +1,5 @@
|
||||
# 阶段1: 构建
|
||||
FROM golang:1.25-alpine AS builder
|
||||
FROM golang:1.26-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache git ca-certificates tzdata
|
||||
|
||||
@@ -11,6 +11,7 @@ ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV CGO_ENABLED=0
|
||||
ENV GOTOOLCHAIN=auto
|
||||
ENV GOPRIVATE=gitea.com/red-future/common
|
||||
|
||||
# 配置git使用私有Gitea仓库
|
||||
RUN git config --global url."http://116.204.74.41:3000/red-future/common.git".insteadOf "https://gitea.com/red-future/common.git" && \
|
||||
git config --global credential.helper store
|
||||
@@ -20,12 +21,13 @@ RUN echo "http://x-token-auth:9b31146aa8c10a7cb4f2e49dcee0934a223be1076289810e1a
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# 先复制go.mod下载依赖
|
||||
COPY go.mod go.sum ./
|
||||
COPY main.go ./
|
||||
COPY config.yml ./
|
||||
|
||||
RUN go mod download && go mod tidy
|
||||
|
||||
# 复制源代码
|
||||
COPY . .
|
||||
|
||||
RUN go build -ldflags="-s -w" -o main ./main.go
|
||||
|
||||
# 阶段2: 运行
|
||||
|
||||
Reference in New Issue
Block a user