Skip to content

Instantly share code, notes, and snippets.

@Sathiyapramod
Created March 16, 2024 07:28
Show Gist options
  • Save Sathiyapramod/d58c9e22d0eb673989c37837ae2fcbf7 to your computer and use it in GitHub Desktop.
Save Sathiyapramod/d58c9e22d0eb673989c37837ae2fcbf7 to your computer and use it in GitHub Desktop.
# Use Node.js 14 image.
# can't find one for 16
# https://hub.docker.com/_/node
FROM node:18
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available).
# Copying this first prevents re-running npm install on every code change.
COPY package*.json ./
# Installing production dependencies only breaks the app
# Install production dependencies.
# If you add a package-lock.json, speed your build by switching to 'npm ci'.
# RUN npm install --only=production
# RUN npm ci --only=production
RUN npm install
# Copy local code to the container image.
COPY . ./
# Run build step
RUN npm run build
# Run the web service on container startup.
CMD [ "node", "./dist/index.js" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment