Skip to content

Instantly share code, notes, and snippets.

@prateekkathal
Last active June 18, 2021 18:50
Show Gist options
  • Save prateekkathal/294e6714e839498da581efaca717a234 to your computer and use it in GitHub Desktop.
Save prateekkathal/294e6714e839498da581efaca717a234 to your computer and use it in GitHub Desktop.
For Medium Article - Using Docker with NestJS (or any NodeJS app)
FROM node:14.17.0-alpine
LABEL maintainer="dev@crowdlinker.com"
# Create app directory
WORKDIR /var/www/backend
# Install app dependencies - For NPM use: `COPY package.json package-lock.lock ./`
COPY package.json yarn.lock ./
# For NPM use: `RUN npm ci`
RUN yarn --pure-lockfile
# Copy important files - Add ormconfig.ts here if using Typeorm
COPY .eslintrc.js nest-cli.json tsconfig.json tsconfig.build.json ./
# Copy env
COPY .env.docker /var/www/backend/.env
# Add storage folder to the container (If you want to add other folder contents to the container)
# ADD storage /var/www/backend/storage
# Entrypoint command - Replace `"yarn"` with `"npm", "run"` if you are using NPM as your package manager.
# You can update this to run other NodeJS apps
CMD [ "yarn", "start:dev", "--preserveWatchOutput" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment