Files
Edu/services/api-gateway/Dockerfile
SpecialX 81a539b9ab
Some checks failed
CI / quality-ts (push) Failing after 6s
CI / quality-go (push) Failing after 25s
CI / quality-proto (push) Failing after 6s
CI / deploy (push) Has been skipped
chore(deps): 统一依赖管理 - pnpm 11 + node:22 + golang:1.25 + python:3.12 + shared-* 集中化
- Node.js 统一到 node:22-alpine,Go 统一到 golang:1.25-alpine,Python 统一到 python:3.12-slim

- pnpm 升级到 11.13.0(corepack),新增 allowBuilds 白名单解决 ERR_PNPM_IGNORED_BUILDS

- 新增 packages/shared-py 集中 Python 共享依赖,shared-ts 补充 graphql-yoga/prom-client

- api-gateway 修复 go.mod 的 shared-go 依赖 + Dockerfile 改用 repo 根作 context

- Python 服务(data-ana/ai)Dockerfile 改用 repo 根作 context + 声明 uv workspace sources

- 16 个服务的 Dockerfile + CI + docker-compose.tools.yml 全部对齐版本矩阵

- known-issues.md 沉淀 9 条 pnpm 11 / uv workspace / Go shared-go 迁移经验

- 验证:4 服务完全成功(api-gateway /healthz 200),其余 install 成功(build 失败为预存 TS 错误)
2026-07-14 12:04:49 +08:00

44 lines
1.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 多阶段构建api-gateway 生产镜像
# 用法docker build -t edu/api-gateway:latest -f services/api-gateway/Dockerfile .
# ============ Builder ============
FROM golang:1.25-alpine AS builder
WORKDIR /app
# git 与 ca-certificates 为 go mod 下载所需
RUN apk add --no-cache git ca-certificates
# 先拷依赖清单利用缓存shared-go + api-gateway
COPY packages/shared-go/go.mod ./packages/shared-go/
COPY services/api-gateway/go.mod services/api-gateway/go.sum ./services/api-gateway/
ENV GOPROXY=https://goproxy.cn,direct
RUN cd services/api-gateway && go mod download
# 拷源码并构建
COPY services/api-gateway ./services/api-gateway
COPY packages/shared-go ./packages/shared-go
RUN cd services/api-gateway && CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w" \
-o /app/bin/api-gateway \
./main.go
# ============ Runtime ============
FROM alpine:3.20 AS runner
WORKDIR /app
RUN apk add --no-cache ca-certificates tzdata wget
# 非 root 用户
RUN addgroup -g 1001 -S app && adduser -S app -u 1001 -G app
COPY --from=builder /app/bin/api-gateway /app/api-gateway
USER app
EXPOSE 8080
# 健康检查
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget --quiet --spider http://localhost:8080/healthz || exit 1
ENTRYPOINT ["/app/api-gateway"]