Files
i-tools/Dockerfile
yfan 999ef5b4c5
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Sync to CNB / sync (push) Has been cancelled
Upstream Sync / Sync latest commits from upstream repo (push) Has been cancelled
Delete old workflow runs / del_runs (push) Has been cancelled
增加C++编译环境
2026-02-06 09:05:58 +08:00

49 lines
1.4 KiB
Docker
Raw Permalink 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.
# 默认使用本地镜像 local-node:20-alpine可先执行: docker tag node:20-alpine local-node:20-alpine
# 也可通过 --build-arg NODE_IMAGE=xxx 指定其他镜像
ARG NODE_IMAGE=node:20-alpine
FROM ${NODE_IMAGE} AS base
FROM base AS deps
# 国内构建若卡在 npm ci可传 --build-arg NPM_REGISTRY=https://registry.npmmirror.com
ARG NPM_REGISTRY=https://registry.npmjs.org/
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm config set registry "$NPM_REGISTRY" \
&& npm config set fetch-timeout 300000 \
&& npm config set fetch-retries 5
# 使用 BuildKit 缓存 npm 目录,二次构建更快
RUN --mount=type=cache,target=/root/.npm \
npm ci
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=production
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# 测试点生成需要编译/运行用户 C++ 标程
RUN apk add --no-cache build-base
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
ENV PORT=3000
EXPOSE 3000
CMD ["node", "server.js"]