node-18-slim / Dockerfile

Where you can copy and paste Dockerfile.

Go back

node-18-slim

node-18-slim

Download via npm

npm init dockerfile@latest node-18-slim

Dockerfile

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" ]


View on GitHub