.dockerignore filenode_modules
dist
.git
Dockerfile
Dockerfile file# Step 1: Use a base image with Node.js
FROM node:18
# Step 2: Set the working directory inside the container
WORKDIR /usr/src/app
# Step 3: Copy package.json and package-lock.json
COPY package*.json ./
# Step 4: Install dependencies
RUN npm install
# Step 5: Copy the rest of the app's source code
COPY . .
# Step 6: Build the TypeScript code
RUN npm run build
# Step 7: Expose the port the app runs on
EXPOSE 3000
# Step 8: Specify the command to run your app
CMD ["node", "dist/index.js"]
Dockerfile for pdf generator project as an exampledocker build -t your-ts-backend:latest .
Get the image name
docker images
Run the image
docker run -it -p 3000:3000 my-image-name
-t (Allocate a pseudo-TTY)i (Keep STDIN open)