mirror of
https://github.com/idootop/mi-gpt.git
synced 2025-04-12 16:49:20 +00:00
chore: 优化 docker runtime 分段构建
This commit is contained in:
parent
020c7030d2
commit
cfb63fe6f9
|
@ -1,14 +1,16 @@
|
||||||
# 排除全部文件
|
# 排除全部文件
|
||||||
**/*
|
**/*
|
||||||
|
|
||||||
# 只保留相关构建文件
|
# 只保留构建相关的文件
|
||||||
!src
|
!src
|
||||||
!prisma
|
|
||||||
!app.js
|
!app.js
|
||||||
!package.json
|
!package.json
|
||||||
!pnpm-lock.yaml
|
!pnpm-lock.yaml
|
||||||
!tsconfig.json
|
!tsconfig.json
|
||||||
!tsup.config.ts
|
!tsup.config.ts
|
||||||
|
!prisma/engines
|
||||||
|
!prisma/migrations
|
||||||
|
!prisma/schema.prisma
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
14
Dockerfile
14
Dockerfile
|
@ -10,20 +10,24 @@ FROM env-$TARGETARCH as base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|
||||||
FROM base as build
|
FROM base as runtime
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN [ ! "$TARGETARCH" = "arm" ] && rm -rf ./prisma/engines || true
|
RUN [ ! "$TARGETARCH" = "arm" ] && rm -rf ./prisma/engines || true
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
npm install -g pnpm@9.1.1
|
npm install -g pnpm@9.1.1
|
||||||
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
|
||||||
pnpm install && pnpm build
|
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
|
FROM base as release
|
||||||
|
|
||||||
COPY app.js .
|
COPY app.js .
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
COPY --from=build /app/dist ./dist
|
COPY --from=dist /app/dist ./dist
|
||||||
COPY --from=build /app/prisma ./prisma
|
COPY --from=dist /app/prisma ./prisma
|
||||||
COPY --from=build /app/node_modules ./node_modules
|
COPY --from=runtime /app/node_modules ./node_modules
|
||||||
|
|
||||||
CMD npm run start
|
CMD npm run start
|
||||||
|
|
Loading…
Reference in New Issue
Block a user