project-knedita/Dockerfile

51 lines
1.2 KiB
Text
Raw Normal View History

2024-01-31 12:58:50 +00:00
# LOCAL
FROM node:20-alpine AS dev
2023-06-20 20:05:15 +00:00
2024-01-31 12:58:50 +00:00
WORKDIR /usr/src/app
2023-06-20 20:05:15 +00:00
2024-01-31 12:58:50 +00:00
COPY --chown=node:node package*.json ./
COPY --chown=node:node prisma ./prisma/
2023-06-20 20:05:15 +00:00
2024-01-31 12:58:50 +00:00
RUN npm ci
2023-06-20 20:05:15 +00:00
2024-01-31 12:58:50 +00:00
COPY --chown=node:node . .
2023-06-20 20:05:15 +00:00
2024-01-31 12:58:50 +00:00
USER node
2024-01-31 12:58:50 +00:00
# BUILD
FROM node:20-alpine AS build
2024-01-31 12:58:50 +00:00
WORKDIR /usr/src/app
2024-01-31 12:58:50 +00:00
COPY --chown=node:node package*.json ./
COPY --chown=node:node --from=dev /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=dev /usr/src/app/prisma ./prisma/
COPY --chown=node:node .husky ./.husky
COPY --chown=node:node tsconfig.json tsconfig.build.json ./
COPY --chown=node:node docker.env ./.env
COPY --chown=node:node . .
2024-01-31 12:58:50 +00:00
RUN npm install husky -g
2024-01-31 12:58:50 +00:00
RUN npm run prisma:generate
2024-01-31 12:58:50 +00:00
RUN npm run build
ENV NODE_ENV production
RUN npm ci --only=production && npm cache clean --force
USER node
# PROD
FROM node:20-alpine as production
2023-07-20 11:15:29 +00:00
2024-01-31 12:58:50 +00:00
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/dist ./dist
COPY --chown=node:node --from=build /usr/src/app/prisma ./prisma
COPY --chown=node:node --from=build /usr/src/app/.husky ./.husky
COPY --chown=node:node --from=build /usr/src/app/.env ./
COPY --chown=node:node --from=build /usr/src/app/package*.json ./
2023-06-20 20:05:15 +00:00
2024-01-31 12:58:50 +00:00
CMD ["npm", "run" , "prod"]