Docker Deployment Guide
This guide explains how to deploy and run the Help Desk application using Docker.
Overview
The Help Desk application includes Docker configuration for easy deployment and containerization. The setup uses a multi-stage build process to create an optimized production image.
Docker Files
Dockerfile
The main Dockerfile uses a multi-stage build:
- Build Stage: Uses Node.js 20 Alpine to build the React application
- Production Stage: Uses Nginx Alpine to serve the static files
docker-compose.yml
Provides a complete service definition with:
- Port mapping (3000:80)
- Health checks
- Volume mounting for logs
- Automatic restart policy
Quick Start
Using Docker Compose (Recommended)
-
Build and run the application:
Terminal window docker-compose up --build -
Run in detached mode:
Terminal window docker-compose up -d --build -
Access the application:
- Open your browser to
http://localhost:3000
- Open your browser to
Using Docker directly
-
Build the image:
Terminal window docker build -t helpdesk-app . -
Run the container:
Terminal window docker run -p 3000:80 helpdesk-app
Configuration Details
Build Process
The Docker build process:
- Copies
react/package*.jsonfiles - Installs dependencies with
npm ci - Copies the entire React application source
- Builds the application with
npm run build - Creates a production Nginx image with the built files
Nginx Configuration
The container includes a custom Nginx configuration for Single Page Application (SPA) routing:
- Serves files from
/usr/share/nginx/html - Handles client-side routing with
try_files - Redirects all routes to
index.htmlfor proper SPA behavior
Health Checks
The docker-compose configuration includes health checks:
- Uses
wgetto test application availability - Checks every 30 seconds
- 10-second timeout
- 3 retries before marking as unhealthy
- 40-second startup grace period
Development vs Production
Development
For development, use the standard development server:
cd reactnpm installnpm run devProduction
For production deployment, use Docker:
docker-compose up -d --buildVolumes and Persistence
Log Files
The docker-compose setup mounts ./logs to /var/log/nginx for log persistence:
volumes: - ./logs:/var/log/nginxPort Configuration
- External Port: 3000 (configurable in docker-compose.yml)
- Internal Port: 80 (Nginx default)
To change the external port, modify the docker-compose.yml:
ports: - "8080:80" # Changes external port to 8080Troubleshooting
Common Issues
-
Port already in use:
Terminal window # Check what's using port 3000lsof -i :3000# Change port in docker-compose.yml or stop conflicting service -
Build failures:
Terminal window # Clean build with no cachedocker-compose build --no-cache -
Application not loading:
Terminal window # Check container logsdocker-compose logs helpdesk# Check container statusdocker ps
Viewing Logs
# View live logsdocker-compose logs -f helpdesk
# View Nginx access logs (if volume mounted)tail -f logs/access.log
# View Nginx error logstail -f logs/error.logStopping the Application
# Stop containersdocker-compose down
# Stop and remove volumesdocker-compose down -v
# Stop and remove imagesdocker-compose down --rmi allEnvironment Variables
Currently, the Docker setup doesnβt use environment variables. Configuration is handled through:
- Firebase configuration in the React application
- Build-time settings in the Vite configuration
Security Considerations
- The container runs Nginx as a non-root user
- Only port 80 is exposed within the container
- Static files are served without execute permissions
- Health checks ensure application availability
Next Steps
For production deployments, consider:
- Adding SSL/TLS termination
- Using a reverse proxy (Traefik, nginx-proxy)
- Implementing monitoring and logging solutions
- Setting up automated backups
- Configuring CI/CD pipelines