Files
infinite-canvas/Dockerfile
T
HouYunFei 2ab499bc54 refactor(server): 调整 Docker 运行架构为 Next.js 代理 Go API
- 修改 Dockerfile 中的运行命令,将 Next.js 设为对外服务,Go 服务在内部监听
- 更新端口配置,后端监听端口从 3000 改为 80
- 移除 Go 服务中的反向代理逻辑,统一由 Next.js 处理页面请求
- 修改 Next.js 配置,在生产环境中也启用 API 代理功能
- 更新文档描述,明确 Next.js 作为页面入口,API 请求代理到 Go 服务
- 调整开发环境端口配置,web 开发端口从 3001 改为 3000
- 更新版本号至 v0.0.4 并修改 CHANGELOG
2026-05-20 13:54:15 +08:00

40 lines
1.2 KiB
Docker

# 构建 Next.js 前端产物。
FROM oven/bun:1 AS web-build
WORKDIR /app/web
COPY web/package.json web/bun.lock ./
RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile --registry=https://registry.npmmirror.com --cache-dir=/root/.bun/install/cache
COPY VERSION /app/VERSION
COPY web ./
RUN bun run build
# 构建 Go 后端入口。
FROM golang:1.25-alpine AS api-build
WORKDIR /app
COPY go.mod go.sum ./
COPY config ./config
COPY handler ./handler
COPY middleware ./middleware
COPY model ./model
COPY repository ./repository
COPY router ./router
COPY service ./service
COPY main.go ./
RUN go build -o /server .
# 运行镜像:Next.js 对外监听 3000,Go 只在容器内部监听 8080。
FROM oven/bun:1
WORKDIR /app
COPY VERSION /app/VERSION
COPY --from=api-build /server /app/server
COPY --from=web-build /app/web /app/web
ENV PROMPT_DATA_DIR=/app/data/prompts
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
RUN mkdir -p /app/data/prompts
EXPOSE 3000
# 先启动内部 Go API,再由 Next.js 提供页面并代理 /api/*。
CMD ["sh", "-c", "PORT=8080 /app/server & cd /app/web && HOSTNAME=0.0.0.0 PORT=3000 bun run start"]