First let's setup a .dockerignore file to prevent our docker build command from copying our node_modules directory into the image.


Now we can create our Dockerfile:

FROM node:alpine AS builder
RUN adduser -S bot
COPY package.json .
RUN npm install
COPY . .
RUN npm run build
# Change to a less-privileged user than root in the
# event a request escapes the sandbox
USER bot
# Starts the bot when the docker container is started
ENTRYPOINT ["npm", "start"]