Optimize docker memory (#976)

This commit is contained in:
ninele7 2023-12-22 05:30:25 +05:00 committed by GitHub
parent c5f8d3373b
commit d8d72074f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 32 additions and 16 deletions

View file

@ -14,18 +14,29 @@ COPY package.json .
COPY yarn.lock .
RUN yarn install --prod
RUN cp -R node_modules /usr/app/prod_node_modules
RUN yarn install
FROM dependencies AS builder
COPY . .
# Run tsc build
RUN yarn prisma generate
RUN yarn build
# Only keep what's necessary to run
FROM base AS runner
WORKDIR /usr/app
COPY --from=dependencies /usr/app/node_modules node_modules
COPY --from=builder /usr/app/dist ./dist
COPY --from=dependencies /usr/app/prod_node_modules node_modules
COPY --from=builder /usr/app/node_modules/.prisma/client ./node_modules/.prisma/client
COPY . .
RUN yarn prisma generate
ARG COMMIT_HASH=unknown
ARG BUILD_DATE=unknown
@ -34,4 +45,4 @@ ENV NODE_ENV production
ENV COMMIT_HASH $COMMIT_HASH
ENV BUILD_DATE $BUILD_DATE
CMD ["tini", "--", "yarn", "start"]
CMD ["tini", "--", "node", "--enable-source-maps", "dist/scripts/migrate-and-start.js"]