Skip to content

Commit

Permalink
feat: docker先暴力构建
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Oct 27, 2023
1 parent d4e6cb3 commit 8408fa9
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ FROM $BASE_IMAGE AS build
WORKDIR /app

COPY package.json package-lock.json ./
COPY packages/server/package.json packages/server ./packages/server/
COPY packages/home/package.json packages/home ./packages/home/
COPY packages/admin/package.json packages/admin ./packages/admin/
RUN npm ci

ENV NODE_ENV=production

COPY packages/server/src ./src
COPY tsconfig.* nest-cli.json ./
RUN npm run build:server
COPY client ./client
RUN npm run build:client
COPY packages packages
RUN npm run build


FROM $BASE_IMAGE AS dependencies

WORKDIR /app

COPY package.json package-lock.json ./
COPY packages/server/package.json packages/server ./packages/server/
COPY packages/home/package.json packages/home ./packages/home/
COPY packages/admin/package.json packages/admin ./packages/admin/
RUN npm ci --omit=dev

FROM $BASE_IMAGE AS release
Expand All @@ -30,8 +33,12 @@ WORKDIR /app

COPY public public
COPY --from=dependencies /app/node_modules ./node_modules
COPY --from=build /app/client/dist ./client/dist
COPY --from=build /app/dist ./dist
COPY --from=dependencies /app/packages/server/node_modules ./packages/server/node_modules
COPY --from=dependencies /app/packages/home/node_modules ./packages/home/node_modules
COPY --from=dependencies /app/packages/admin/node_modules ./packages/admin/node_modules
COPY --from=build /app/packages/server/dist ./packages/server/dist
COPY --from=build /app/packages/home/dist ./packages/home/dist
COPY --from=build /app/packages/admin/dist ./packages/admin/dist

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "--enable-source-maps", "dist/main.js"]
CMD ["node", "--enable-source-maps", "packages/server/dist/main.js"]

0 comments on commit 8408fa9

Please sign in to comment.