dockerfile修改
This commit is contained in:
53
Dockerfile
53
Dockerfile
@@ -1,27 +1,44 @@
|
||||
# 最小化Docker镜像
|
||||
FROM busybox:uclibc
|
||||
# 多阶段构建 - 第一阶段:编译(使用已安装的镜像)
|
||||
FROM golang:1.26-alpine3.23 AS builder
|
||||
|
||||
RUN apk add --no-cache git ca-certificates tzdata
|
||||
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV CGO_ENABLED=0
|
||||
ENV GOTOOLCHAIN=auto
|
||||
ENV GOPRIVATE=gitea.com/red-future/common
|
||||
|
||||
# 配置git使用私有Gitea仓库(带Token认证)
|
||||
RUN git config --global url."http://x-token-auth:9b31146aa8c10a7cb4f2e49dcee0934a223be1076289810e1ad98b968066c2bc@116.204.74.41:3000/red-future/common.git".insteadOf "https://gitea.com/red-future/common.git" && \
|
||||
git config --global credential.helper store
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# 复制父目录的 common 模块(因为 go.mod 中使用了本地 replace)
|
||||
#COPY ../common /build/common
|
||||
COPY . .
|
||||
|
||||
RUN go mod download && go mod tidy
|
||||
|
||||
RUN go build -ldflags="-s -w" -o main ./main.go
|
||||
|
||||
# 第二阶段:运行
|
||||
FROM alpine:3.23
|
||||
|
||||
ENV TIME_ZONE=Asia/Shanghai
|
||||
RUN apk add --no-cache ca-certificates tzdata && \
|
||||
ln -sf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 复制时区数据
|
||||
COPY timezone/localtime /etc/localtime
|
||||
COPY timezone/timezone /etc/timezone
|
||||
COPY timezone/Shanghai /usr/share/zoneinfo/Asia/Shanghai
|
||||
|
||||
# 复制预构建的二进制文件和配置文件
|
||||
COPY app ./main
|
||||
COPY manifest/config/config.yaml ./manifest/config/config.yaml
|
||||
COPY manifest/config/config-dev.yaml ./manifest/config/config-dev.yaml
|
||||
COPY manifest/config/config-master.yaml ./manifest/config/config-master.yaml
|
||||
COPY resource ./resource
|
||||
# 复制编译好的二进制文件
|
||||
COPY --from=builder /build/main .
|
||||
COPY --from=builder /build/config.yml ./
|
||||
|
||||
# 创建日志目录
|
||||
RUN mkdir -p /logs /app/resource/log/run /app/resource/log/server
|
||||
|
||||
# 添加执行权限
|
||||
RUN chmod +x /app/main
|
||||
EXPOSE 8808
|
||||
|
||||
EXPOSE 9001
|
||||
|
||||
# 使用root用户运行
|
||||
CMD ["./main"]
|
||||
|
||||
4
go.mod
4
go.mod
@@ -3,7 +3,7 @@ module github.com/tiger1103/gfast/v3
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
gitea.com/red-future/common v0.0.12
|
||||
gitea.com/red-future/common v0.0.16
|
||||
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef
|
||||
github.com/casbin/casbin/v2 v2.42.0
|
||||
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.10.0
|
||||
@@ -16,7 +16,7 @@ require (
|
||||
github.com/tiger1103/gfast-token v1.0.10
|
||||
)
|
||||
|
||||
replace gitea.com/red-future/common v0.0.12 => ../common
|
||||
//replace gitea.com/red-future/common v0.0.12 => ../common
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.5.0 // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@@ -1,4 +1,6 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
gitea.com/red-future/common v0.0.16 h1:nQ2qSxr4MAJfKRGmL00L2e3/K3JqEkNNpr4bxCZYhMM=
|
||||
gitea.com/red-future/common v0.0.16/go.mod h1:6/nqIucVzmjOyqDTIq71feYBXXFNBy0rFwzaQ0/Ueoo=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
server:
|
||||
name: "admin-go"
|
||||
address: ":9001"
|
||||
address: ":8808"
|
||||
serverRoot: "resource/public"
|
||||
dumpRouterMap: false
|
||||
routeOverWrite: true
|
||||
@@ -105,7 +105,7 @@ gfcli:
|
||||
path: "./internal/app/system"
|
||||
|
||||
# 文件上传服务地址,与oss模块minio中的endpoint(filePrefix需要加http://)一致
|
||||
filePrefix: "http://172.17.0.3:9000"
|
||||
filePrefix: "http://116.204.74.41:9000"
|
||||
|
||||
consul:
|
||||
address: 116.204.74.41:8500
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
Asia/Shanghai
|
||||
Reference in New Issue
Block a user