A Dockerfile describes how to build an image for your app. Copying package files before the rest of the code lets Docker reuse the cached install step when only your code changes.
# Dockerfile for a Node.js app FROM node:22-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --omit=dev COPY . . USER node EXPOSE 3000 CMD ["node", "server.js"] # build and run: docker build -t myapp . docker run -d -p 3000:3000 myapp