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