Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 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
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.
Expand Down