From 5f228b551bdeb0fa9e2c0786095ae55d042dd79e Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 19 May 2025 07:28:51 +0000 Subject: [PATCH 1/2] Added Dockerfile to containerized the application --- Dockerfile | 34 ++++++++++++++++++++++++++++++++++ README.md | 18 +++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..008412b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# Stage 1: Build the app +FROM node:18-alpine AS builder + +WORKDIR /app + +# Copy only package files first for caching +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the source code +COPY . . + +# Build the production static files +RUN npm run build + + +# Stage 2: Run the built app using a minimal Node image +FROM node:18-alpine AS runner + +# Install serve globally +RUN npm install -g serve + +# Create working directory +WORKDIR /app + +# Copy only the built static files from builder stage +COPY --from=builder /app/build ./build + +# Serve the static files +CMD ["serve", "-s", "build", "-l", "3000"] + +EXPOSE 3000 diff --git a/README.md b/README.md index b1fe6dd..14063da 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ See the live project in action: https://react-js-simple-calculator.netlify.app/ - HTML - CSS - JS - +- Docker ## Getting Started To get a local copy up and running, follow these steps: @@ -31,6 +31,22 @@ To get a local copy up and running, follow these steps: 3. Install dependencies: `npm install` 4. Start the development server: `npm start` +## You Can Run Project directly in using Docker(ubuntu os) + +1. Install Docker in ubuntu operating system + - update o.s i.e. sudo apt-get update --y + - install doker i.e. sudo apt-get install docker.io +2. Give permissions to access docker images and containers without sudo user + - sudo useradd -aG docker $USER + - sudo chmod 666 /var/run/docker.sock +3. Build the docker image using below command + - docker build -t calapp . +4. Run the docker container using below command + - docker run -itd -p 3000:3000 --name=calapp calapp +5. Check the containers are up or not + - docker ps +6. Access Your application on 3000 port. + ## Usage 1. Click the buttons to input numbers and operators. From 6a67cf11985b55756264ee1e3a6ffa51205dd36b Mon Sep 17 00:00:00 2001 From: sasibeeke <42212652+sasibeeke@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:57:29 +0530 Subject: [PATCH 2/2] Update README.md Done --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14063da..3a3f3bc 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ To get a local copy up and running, follow these steps: 1. Install Docker in ubuntu operating system - update o.s i.e. sudo apt-get update --y - - install doker i.e. sudo apt-get install docker.io + - install docker i.e. sudo apt-get install docker.io 2. Give permissions to access docker images and containers without sudo user - sudo useradd -aG docker $USER - sudo chmod 666 /var/run/docker.sock