Where you can copy and paste Dockerfile.
Go backnode-18-slim
npm init dockerfile@latest node-18-slim
FROM node:18-slim
# Create a new directory for the project
RUN mkdir -p /opt/app
# Change current working directory
WORKDIR /opt/app
# Copy package files
COPY package*.json ./
# Set our env to be in CI
ENV CI true
ENV NODE_ENV production
RUN npm ci
# Copy our project files
COPY . .
# Change directory's owner
RUN chown -R node /opt/app
# Specify running user
USER node
# Port of the application
EXPOSE 8080
CMD [ "node", "main.js" ]