Initial commit

This commit is contained in:
theshy
2025-08-14 23:00:16 +08:00
commit 088c3d2044
11 changed files with 1253 additions and 0 deletions

35
Dockerfile Normal file
View File

@ -0,0 +1,35 @@
# syntax=docker/dockerfile:1
# 1) 构建阶段:安装仅生产依赖
FROM node:22-bookworm-slim AS builder
WORKDIR /app
ENV NODE_ENV=production
# 仅复制依赖清单,提升缓存命中率
COPY package.json package-lock.json* ./
# 无锁文件时回退 npm install并关闭审计/基金提示
RUN if [ -f package-lock.json ]; then \
npm ci --omit=dev --no-audit --no-fund; \
else \
npm install --omit=dev --no-audit --no-fund; \
fi
# 复制应用源码
COPY index.js ./index.js
COPY src ./src
COPY public ./public
# 2) 运行阶段Debian 12 distroless极简、无 Shell
FROM gcr.io/distroless/nodejs22-debian12
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app /app
EXPOSE 8080
USER nonroot:nonroot
# distroless nodejs 以 node 为入口,传入脚本路径即可
CMD ["/app/index.js"]