Compare commits
2
Commits
9bfe1ec120
...
65e0b26d8d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65e0b26d8d | ||
|
|
1a64b2e98e |
@@ -2,6 +2,7 @@
|
||||
FROM golang:1.25-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build -o pr-helper .
|
||||
|
||||
@@ -60,25 +60,7 @@ setup_docker_mirror() {
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# 3. 注入 Go 模块代理到 Dockerfile
|
||||
# ----------------------------------------------------------
|
||||
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 配置文件
|
||||
# 3. 读取 .env 配置文件
|
||||
# ----------------------------------------------------------
|
||||
load_env() {
|
||||
if [ ! -f ".env" ]; then
|
||||
@@ -152,7 +134,6 @@ main() {
|
||||
|
||||
check_docker
|
||||
setup_docker_mirror
|
||||
setup_go_proxy
|
||||
load_env
|
||||
build_and_start
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user