Files
Next_Knowledge_Base/Dockerfile
T
2026-06-23 19:21:36 +08:00

35 lines
1.0 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.
FROM knowledge-base-base:latest
# 安装 nginx 和 htpasswd 工具
RUN apk add --no-cache nginx apache2-utils
WORKDIR /app
# 复制包管理文件,利用 Docker 层缓存
# pnpm.json 包含 overridespnpm v10+ 从此文件读取,不再读 package.json 的 pnpm 字段)
COPY package.json pnpm-lock.yaml pnpm.json ./
# 禁用 minimumReleaseAge 供应链策略(CI 环境使用已审核的锁文件,无需此检查)
RUN pnpm config set minimum-release-age 0 && pnpm install --frozen-lockfile
# 复制源码
COPY . .
# NEXT_PUBLIC_* 变量在构建时嵌入,通过 build-arg 传入
ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
RUN pnpm build
# 配置 nginx
COPY nginx.conf /etc/nginx/http.d/default.conf
# 入口脚本:生成 htpasswd -> 启动 Next.js -> 启动 nginx
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]