Dockerfile

This commit is contained in:
2026-04-01 13:04:59 +08:00
parent 21ec536c57
commit 5fe9879b84
2 changed files with 60 additions and 9 deletions

51
Dockerfile Normal file
View File

@@ -0,0 +1,51 @@
# 阶段1: 构建
FROM golang:1.25-alpine AS builder
RUN apk add --no-cache git ca-certificates tzdata
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
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仓库
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
# 阶段2: 运行
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
COPY --from=builder /build/main .
COPY --from=builder /build/config.yml ./
RUN mkdir -p /app/resource/log/run \
/app/resource/log/server \
&& adduser -D -u 1000 appuser \
&& chown -R appuser:appuser /app
USER appuser
EXPOSE 8000
CMD ["./main"]

View File

@@ -56,10 +56,10 @@ database:
timeMaintainDisabled: false # (可选)是否完全关闭时间更新特性为true时CreatedAt/UpdatedAt/DeletedAt都将失效
tenant-1:
- type: "pgsql"
host: "localhost"
port: "5432"
host: "116.204.74.41"
port: "15432"
user: "postgres"
pass: "123456"
pass: "Bjang09@686^*^"
name: "tenant"
role: "master"
prefix: "assets_" # (可选)表名前缀
@@ -79,7 +79,7 @@ database:
redis:
# 集群模式配置方法
default:
address: localhost:6379
address: 116.204.74.41:6379
db: 0
idleTimeout: "60s"
maxConnLifetime: "90s"
@@ -89,7 +89,7 @@ redis:
writeTimeout: "30s"
maxActive: 100
test:
address: localhost:6379
address: 116.204.74.41:6379
db: 1
idleTimeout: "60s"
maxConnLifetime: "90s"
@@ -100,14 +100,14 @@ redis:
maxActive: 100
consul:
address: localhost:8500
address: 116.204.74.41:8500
jaeger:
addr: localhost:4318
addr: 116.204.74.41:4318
nats:
default:
url: "nats://localhost:4222"
url: "nats://116.204.74.41:4222"
# 文件上传服务地址与oss模块minio中的endpoint一致
filePrefix: "http://116.204.74.41:9000"
@@ -119,7 +119,7 @@ cache:
gmq:
redis:
primary:
addr: "localhost"
addr: "116.204.74.41"
port: "6379"
db: 0
username: ""