Compare commits

...
2 Commits
2 changed files with 2 additions and 20 deletions
+1
View File
@@ -2,6 +2,7 @@
FROM golang:1.25-alpine AS builder FROM golang:1.25-alpine AS builder
WORKDIR /app WORKDIR /app
COPY go.mod go.sum ./ COPY go.mod go.sum ./
ENV GOPROXY=https://goproxy.cn,direct
RUN go mod download RUN go mod download
COPY . . COPY . .
RUN CGO_ENABLED=0 go build -o pr-helper . RUN CGO_ENABLED=0 go build -o pr-helper .
+1 -20
View File
@@ -60,25 +60,7 @@ setup_docker_mirror() {
} }
# ---------------------------------------------------------- # ----------------------------------------------------------
# 3. 注入 Go 模块代理到 Dockerfile # 3. 读取 .env 配置文件
# ----------------------------------------------------------
setup_go_proxy() {
local dockerfile="Dockerfile"
local proxy_env="GOPROXY=https://goproxy.cn,direct"
if grep -q "GOPROXY" "$dockerfile"; then
warn "Dockerfile 已配置 GOPROXY,跳过"
return
fi
info "注入 Go 模块代理到 Dockerfile..."
# 在 builder 阶段的 RUN go mod download 之前注入 ENV
sed -i "/^RUN go mod download$/i ENV ${proxy_env}" "$dockerfile"
info "Go 模块代理配置完成"
}
# ----------------------------------------------------------
# 4. 读取 .env 配置文件
# ---------------------------------------------------------- # ----------------------------------------------------------
load_env() { load_env() {
if [ ! -f ".env" ]; then if [ ! -f ".env" ]; then
@@ -152,7 +134,6 @@ main() {
check_docker check_docker
setup_docker_mirror setup_docker_mirror
setup_go_proxy
load_env load_env
build_and_start build_and_start
} }