Docker basics
touch Dockerfilenano Dockerfile# Use an official Node.js runtime as a parent image
FROM node:18
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install Node.js dependencies
RUN npm install
# Copy the rest of your application code to the container
COPY . .
# Expose the port your app will run on (e.g., 3000)
EXPOSE 3000
# Define the command to run your Node.js application
CMD ["node", "app.js"]
Last updated