mirror of
https://github.com/idootop/mi-gpt.git
synced 2025-04-21 21:19:50 +00:00
refactor: 优化 docker 镜像构建流程
This commit is contained in:
parent
a260cb117d
commit
020c7030d2
28
Dockerfile
28
Dockerfile
@ -1,31 +1,29 @@
|
|||||||
# syntax=docker/dockerfile:1
|
FROM node:20.14.0-alpine as env-amd64
|
||||||
|
FROM node:20.14.0-alpine as env-arm64
|
||||||
# base
|
FROM arm32v7/node:20.14.0 as env-arm
|
||||||
FROM node:18-alpine as base
|
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
|
WORKDIR /app
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
# build
|
|
||||||
FROM base as build
|
FROM base as build
|
||||||
|
COPY . .
|
||||||
|
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
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
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 && pnpm build
|
||||||
|
|
||||||
# run
|
FROM base as release
|
||||||
FROM base
|
|
||||||
|
|
||||||
|
COPY app.js .
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
COPY --from=build /app/dist ./dist
|
COPY --from=build /app/dist ./dist
|
||||||
COPY --from=build /app/scripts ./scripts
|
|
||||||
COPY --from=build /app/prisma ./prisma
|
COPY --from=build /app/prisma ./prisma
|
||||||
COPY --from=build /app/node_modules ./node_modules
|
COPY --from=build /app/node_modules ./node_modules
|
||||||
|
|
||||||
RUN rm -rf ./prisma/engines
|
|
||||||
|
|
||||||
# Run the application.
|
|
||||||
CMD npm run start
|
CMD npm run start
|
||||||
|
Loading…
x
Reference in New Issue
Block a user