Skip to content

Instantly share code, notes, and snippets.

@mcorkum
Created September 17, 2022 12:58
Show Gist options
  • Save mcorkum/95ce3cd2dfd709667506bdc709ed8a12 to your computer and use it in GitHub Desktop.
Save mcorkum/95ce3cd2dfd709667506bdc709ed8a12 to your computer and use it in GitHub Desktop.
# Install dependencies
FROM node:16 AS dependencies
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# Run yarn build
FROM node:16 AS builder
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
RUN yarn build
# Production image, copy all the files and run next
FROM node:16 AS runner
WORKDIR /app
ENV NODE_ENV production
COPY --from=builder --chown=node:node /app/. .
# default to port 80 for node, and 9229 and 9230 (tests) for debug
ARG PORT=80
ENV PORT $PORT
EXPOSE $PORT 9229 9230
CMD [ "yarn", "run", "start" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment