Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

nestjs Dockerfile

FROM node:16-alpine as builder

ENV NODE_ENV build

USER node
WORKDIR /home/node

COPY package*.json ./
RUN npm ci

COPY --chown=node:node . .
RUN npm run build 
    && npm prune --production

# ---

FROM node:16-alpine

ENV NODE_ENV production

USER node
WORKDIR /home/node

COPY --from=builder --chown=node:node /home/node/package*.json ./
COPY --from=builder --chown=node:node /home/node/node_modules/ ./node_modules/
COPY --from=builder --chown=node:node /home/node/dist/ ./dist/

CMD ["node", "dist/server.js"]
Comment

nestjs dockerfile

###################
# BUILD FOR LOCAL DEVELOPMENT
###################

FROM node:18-alpine As development

WORKDIR /usr/src/app

COPY --chown=node:node package*.json ./

RUN npm ci

COPY --chown=node:node . .

USER node

###################
# BUILD FOR PRODUCTION
###################

FROM node:18-alpine As build

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 --only=production && npm cache clean --force

USER node

###################
# PRODUCTION
###################

FROM node:18-alpine As production

COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/dist ./dist

CMD [ "node", "dist/main.js" ]
Comment

PREVIOUS NEXT
Code Example
Shell :: how to exit vim 
Shell :: install next app 
Shell :: present working directory in shell script 
Shell :: composer install global 
Shell :: [!] Android Studio (version 4.1.0) X Flutter plugin not installed; this adds Flutter specific functionality. X Dart plugin not installed; this adds Dart specific functionality. 
Shell :: install oh my zsh 
Shell :: git commit to a new branch 
Shell :: nuxt install pug 
Shell :: git fetch and checkout branch 
Shell :: double quotes inside double quotes bash 
Shell :: how to check if docker is installed 
Shell :: string to array bash 
Shell :: hwo to add custom commands in bash 
Shell :: valgrind memory leak 
Shell :: install rsync 
Shell :: set email git 
Shell :: One command to create a directory and file inside it linux command 
Shell :: git get remote branches 
Shell :: failed to push some refs to repository 
Shell :: git diff meld 
Shell :: pesquisar git 
Shell :: how to exit git rebase 
Shell :: fusion 360 on linux 
Shell :: reconfigure postfix 
Shell :: how to see how big a file is ubuntu terminal 
Shell :: how to install jupyter 
Shell :: git add email 
Shell :: adonis make migration 
Shell :: linux get user id 
Shell :: read last line file bash 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =