首次提交:初始化项目代码
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# 多阶段构建,减小最终镜像体积
|
||||
FROM golang:1.22-alpine AS builder
|
||||
WORKDIR /src
|
||||
|
||||
# 先复制 go.mod / go.sum 并下载依赖,利用 Docker 缓存
|
||||
COPY go.mod go.sum* ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
# 静态二进制,方便在 alpine 中运行
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/auth-service ./cmd/auth-service
|
||||
|
||||
FROM alpine:3.19
|
||||
RUN apk --no-cache add ca-certificates tzdata && adduser -D -u 10001 app
|
||||
WORKDIR /app
|
||||
COPY --from=builder /out/auth-service /app/auth-service
|
||||
USER app
|
||||
EXPOSE 8081
|
||||
ENTRYPOINT ["/app/auth-service"]
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM golang:1.22-alpine AS builder
|
||||
WORKDIR /src
|
||||
|
||||
COPY go.mod go.sum* ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/file-service ./cmd/file-service
|
||||
|
||||
FROM alpine:3.19
|
||||
RUN apk --no-cache add ca-certificates tzdata && adduser -D -u 10002 app
|
||||
WORKDIR /app
|
||||
COPY --from=builder /out/file-service /app/file-service
|
||||
USER app
|
||||
EXPOSE 8082
|
||||
ENTRYPOINT ["/app/file-service"]
|
||||
Reference in New Issue
Block a user