Skip to main content

Quick start

Get the application up and running on your local machine in under 5 minutes using Docker Compose. This guide will walk you through the entire process from cloning the repository to accessing the running application.

Prerequisites

Before you begin, ensure you have the following installed on your system:
  • Docker: Version 20.10 or higher (Install Docker)
  • Docker Compose: Version 2.0 or higher (usually included with Docker Desktop)
  • Git: For cloning the repository
You don’t need Node.js or npm installed locally. Everything runs inside Docker containers.

Getting started

1

Clone the repository

Clone the project repository to your local machine:
git clone https://github.com/mani-6666/Mini-Project.git
cd Mini-Project
2

Build and start the application

Use Docker Compose to build the multi-stage Docker image and start the container:
docker-compose up --build
This command will:
  • Build the React frontend using Node.js 18 Alpine
  • Install Express backend dependencies
  • Create an optimized production image
  • Start the container and expose port 5000
The initial build may take 2-3 minutes as Docker downloads base images and installs dependencies. Subsequent builds will be much faster thanks to Docker’s layer caching.
3

Verify the application is running

Once the container starts, you should see:
 Server running on port 5000
Open your browser and navigate to:
http://localhost:5000
You should see the message:
Hello, This is from Mini project Deployment!

Docker Compose configuration

The application uses a simple Docker Compose setup defined in docker-compose.yml:
docker-compose.yml
version: '3.8'
services:
  app:
    build: .
    ports:
      - "5000:5000"
    container_name: miniproject
This configuration:
  • Uses Docker Compose version 3.8
  • Builds the image from the Dockerfile in the current directory
  • Maps port 5000 from the container to port 5000 on your host machine
  • Names the container miniproject for easy reference

Understanding the build process

The Dockerfile uses a three-stage build process to create an optimized production image:
FROM node:18-alpine AS frontend-build
WORKDIR /app

# Install frontend dependencies
COPY client/package*.json ./client/
RUN cd client && npm install

# Build frontend
COPY client ./client
RUN cd client && npm run build
This multi-stage approach ensures only the production artifacts make it into the final image, significantly reducing image size.

Managing the application

Stop the application

To stop the running container, press Ctrl+C in the terminal where Docker Compose is running, or run:
docker-compose down

Run in detached mode

To run the application in the background:
docker-compose up -d
View logs with:
docker-compose logs -f

Rebuild after code changes

If you make changes to the code, rebuild and restart:
docker-compose up --build

Troubleshooting

Port 5000 already in use

If you see an error about port 5000 being in use, either:
  1. Stop the application using that port
  2. Modify docker-compose.yml to use a different port:
    ports:
      - "3000:5000"  # Access via localhost:3000
    

Container won’t start

Check the container logs:
docker logs miniproject

Clean rebuild

To rebuild from scratch without cache:
docker-compose build --no-cache
docker-compose up

Next steps

Now that you have the application running locally, you can:

Explore the Docker setup

Learn about the multi-stage build process and optimization techniques

Set up Jenkins CI/CD

Automate your deployment with Jenkins pipeline

Build docs developers (and LLMs) love