Skip to content

Instantly share code, notes, and snippets.

@harrylowkey
Last active July 3, 2023 03:01
Show Gist options
  • Save harrylowkey/024e050bc205f60d2add37b7a68d0515 to your computer and use it in GitHub Desktop.
Save harrylowkey/024e050bc205f60d2add37b7a68d0515 to your computer and use it in GitHub Desktop.
Dockerfile for Nodejs server
FROM node:18-alpine As development
RUN apk update && apk add --no-cache bash git openssh
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
ADD . .
RUN npm run build
FROM node:18-alpine as production
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci --only=production
COPY --from=development /usr/src/app/dist ./dist
COPY --from=development /usr/src/app/node_modules/ ./node_modules/
EXPOSE 3000
CMD ["node", "/usr/src/app/dist/main.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment