51 lines
1.1 KiB
Docker
51 lines
1.1 KiB
Docker
|
###################
|
||
|
# BUILD FOR LOCAL DEVELOPMENT
|
||
|
###################
|
||
|
|
||
|
FROM node:18-alpine As development
|
||
|
|
||
|
USER node
|
||
|
WORKDIR /usr/src/app
|
||
|
|
||
|
COPY --chown=node:node package*.json ./
|
||
|
|
||
|
RUN npm ci
|
||
|
|
||
|
COPY --chown=node:node . .
|
||
|
|
||
|
###################
|
||
|
# BUILD FOR PRODUCTION
|
||
|
###################
|
||
|
|
||
|
FROM node:18-alpine As build
|
||
|
|
||
|
USER node
|
||
|
WORKDIR /usr/src/app
|
||
|
|
||
|
COPY --chown=node:node package*.json ./
|
||
|
COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modules
|
||
|
COPY --chown=node:node . .
|
||
|
|
||
|
RUN npm run build
|
||
|
|
||
|
ENV NODE_ENV production
|
||
|
|
||
|
RUN npm ci --omit=dev && npm cache clean --force
|
||
|
|
||
|
###################
|
||
|
# PRODUCTION
|
||
|
###################
|
||
|
|
||
|
FROM node:18-alpine As production
|
||
|
|
||
|
USER node
|
||
|
WORKDIR /app
|
||
|
|
||
|
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/views ./views
|
||
|
COPY --chown=node:node --from=build /usr/src/app/public ./public
|
||
|
COPY --chown=node:node --from=build /usr/src/app/package*.json ./package*.json
|
||
|
|
||
|
CMD [ "node", "dist/main.js" ]
|