0% found this document useful (0 votes)
13 views6 pages

Assignment # 2 - DevOps

The document outlines an assignment involving the creation and execution of Dockerfiles for a React application. It details the process of building a standard Docker image and a multi-stage lightweight Docker image, resulting in a significant reduction in image size from 1.29 GB to 48.5 MB. Both versions of the React app are successfully run in parallel on specified ports.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Assignment # 2 - DevOps

The document outlines an assignment involving the creation and execution of Dockerfiles for a React application. It details the process of building a standard Docker image and a multi-stage lightweight Docker image, resulting in a significant reduction in image size from 1.29 GB to 48.5 MB. Both versions of the React app are successfully run in parallel on specified ports.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

ASSIGNMENT # O2

Ayesha Salman – 29418

Task 01. Create a Simple Dockerfile for the reactapp. ( For Example yourname-
reactapp-image )

Github repository cloned for reactapp

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.

Task 03. Check the image size.

Image size is 1.29gb for the first image.


Task 04. Create Multi Stage Dockerfile for the same reactapp. ( For Example
yourname-reactapp-image-lw ) lw = lightweight

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 )

image size is now reduced to 48.5mg from 1.29 gb.

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

Task 07. Reactapp from both Dockerfiles needs to be running in parallel.

You might also like