Assignment # 2 - DevOps
Assignment # 2 - DevOps
Task 01. Create a Simple Dockerfile for the reactapp. ( For Example yourname-
reactapp-image )
Task 02. Run the docker application from the created image. ( For Example
yourname-reactapp )
Docker.simple file created for reactapp directory with image name ayesha-reactapp-
image and port 3044
Below attached Dockerfile sets up a Node.js environment to build and serve a React
application. It has installed dependencies, builds the app, installs the serve package
globally, and then serves the production-ready build on port 3000 using the serve
command.
Successful execution of reactapp on 3044 port.
The new Dockerfile.02 uses multi-stage builds to create a production-ready React app
with a smaller image size.
• In Stage 1, it uses node:14 to install dependencies and build the React app.
• In Stage 2, it uses the lightweight nginx:alpine image to serve the compiled static
files.
This approach significantly reduces the final Docker image size by excluding
unnecessary development tools and files.
New image with lightweight created as ayesha-reactapp-02 created on port 8044.
Task 05. Now check the Image size of it ( It should be drastically smaller in mbs )
Task 06. Run the docker application from the smaller created image. ( For Example
yourname-reactapp-lw )
Successful execution of reactapp on this new lightweight image