36 lines
890 B
Docker
36 lines
890 B
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# ---- 依赖 ----
|
|
FROM node:24-alpine AS deps
|
|
WORKDIR /app
|
|
RUN npm i -g pnpm@10.5.2
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# ---- 构建 ----
|
|
FROM node:24-alpine AS build
|
|
WORKDIR /app
|
|
RUN npm i -g pnpm@10.5.2
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN pnpm build
|
|
|
|
# ---- 运行 ----
|
|
FROM node:24-alpine AS runtime
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=3000
|
|
|
|
COPY --from=build /app/dist ./dist
|
|
COPY --from=build /app/node_modules ./node_modules
|
|
COPY --from=build /app/package.json ./package.json
|
|
COPY --from=build /app/migrations ./migrations
|
|
COPY --from=build /app/scripts ./scripts
|
|
|
|
# OG 图由 sharp -> librsvg 渲染文字,需要 fontconfig + Latin 字体
|
|
RUN apk add --no-cache fontconfig ttf-dejavu && mkdir -p /app/data
|
|
|
|
EXPOSE 3000
|
|
CMD ["node", "./dist/server/entry.mjs"]
|