Skip to content

Instantly share code, notes, and snippets.

@jmaicaaan
Created January 31, 2021 12:35
Show Gist options
  • Save jmaicaaan/6e0b4b50012b56f949260b06d72174dd to your computer and use it in GitHub Desktop.
Save jmaicaaan/6e0b4b50012b56f949260b06d72174dd to your computer and use it in GitHub Desktop.
[Tutorial] Dockerizing Next.js - Dockerfile
# base image
FROM node:14.15.4-alpine
# Create and change to the app directory.
WORKDIR /usr/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 . .
# Install production dependencies.
# If you add a package-lock.json, speed your build by switching to 'npm ci'.
RUN npm ci --only=production
# Copy local code to the container image.
RUN npm run build
# Run the web service on container startup.
CMD [ "npm", "start" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment