加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Dockerfile 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
WJG 提交于 2024-06-02 11:49 . chore: 优化 docker runtime 分段构建
FROM node:20.14.0-alpine as env-amd64
FROM node:20.14.0-alpine as env-arm64
FROM arm32v7/node:20.14.0 as env-arm
ENV PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING=1
ENV PRISMA_QUERY_ENGINE_BINARY=/app/prisma/engines/query-engine
ENV PRISMA_QUERY_ENGINE_LIBRARY=/app/prisma/engines/libquery_engine.so.node
ENV PRISMA_SCHEMA_ENGINE_BINARY=/app/prisma/engines/schema-engine
FROM env-$TARGETARCH as base
WORKDIR /app
ARG TARGETARCH
FROM base as runtime
COPY . .
RUN [ ! "$TARGETARCH" = "arm" ] && rm -rf ./prisma/engines || true
RUN --mount=type=cache,target=/root/.npm \
npm install -g pnpm@9.1.1
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --production && pnpm prisma generate
FROM runtime as dist
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install && pnpm tsup
FROM base as release
COPY app.js .
COPY package.json .
COPY --from=dist /app/dist ./dist
COPY --from=dist /app/prisma ./prisma
COPY --from=runtime /app/node_modules ./node_modules
CMD npm run start
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化