Youtube Video Link: https://youtu.be/7FGj4EwOX2E
This project sets up a basic Node.js server that serves an HTML file. The server is then containerized using Docker.
index.html: The HTML file to be served.server.js: The Node.js server code.Dockerfile: Instructions to build the Docker image..dockerignore: Specifies which files and directories to ignore when building the Docker image.package.json: Contains the project metadata and dependencies.
-
Clone the repository:
git clone https://github.com/yourusername/my-node-server.git cd my-node-server -
Install dependencies (if any):
npm install
-
Start the server:
npm start
-
Open your browser and navigate to
http://localhost:3000.
-
Clone the repository (if you haven't already):
https://github.com/codewithmuh/dockerize-nodejs.git cd my-node-server
-
Build the Docker image:
docker build -t my-node-server . -
Run the Docker container:
docker run -it --rm -p 3000:3000 my-node-server
-
Open your browser and navigate to
http://localhost:3000.
-
Build the Docker image:
docker build -f Dockerfile-distroless -t my-node-cg . -
Run the Docker container:
docker run -it --rm -p 3000:3000 my-node-cg
-
Open your browser and navigate to
http://localhost:3000.
