The Centinela water treatment monitoring system uses a multi-stage Docker build process to create optimized production containers. This guide covers building and running the application with Docker.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/CspmIT/centinela-front/llms.txt
Use this file to discover all available pages before exploring further.
Docker Architecture
The Dockerfile uses a two-stage build process:- Build Stage: Compiles the React/Vite application with all environment variables
- Runtime Stage: Serves the static files using Nginx Alpine
Prerequisites
Before deploying with Docker, ensure you have:- Docker installed (version 20.10 or higher)
- Docker Compose (optional, for orchestrated deployments)
- Environment variables prepared (see Environment Variables)
Building the Docker Image
Build with environment arguments
Build the Docker image with required environment variables as build arguments:
Environment variables are baked into the build at compile time. You must rebuild the image if you need to change these values.
Running the Container
Once built, run the container with the following command:Run container in detached mode (background)
Assign a name to the container for easier management
Map host port 80 to container port 80. Adjust as needed (e.g.,
8080:80)Container restart policy. Options:
no, on-failure, always, unless-stoppedDocker Build Process Details
Here’s what happens during the multi-stage build:Build Stage
- Uses Node.js Alpine for a lightweight build environment
- Accepts build arguments for environment configuration
- Installs dependencies and builds the Vite application
- Outputs compiled assets to
/app/dist
Runtime Stage
- Uses Nginx Alpine for minimal production footprint
- Copies built assets from the build stage
- Applies custom Nginx configuration for SPA routing
- Exposes port 80 for web traffic
Docker Compose Example
For easier deployment management, create adocker-compose.yml file:
docker-compose.yml
Container Management
Viewing Logs
Stopping and Starting
Removing Containers
Image Optimization
The multi-stage build provides significant size benefits:| Stage | Size | Contents |
|---|---|---|
| Build | ~500MB | Node.js + dependencies + source code |
| Runtime | ~50MB | Nginx + compiled assets only |
The final production image is approximately 90% smaller than a single-stage build, resulting in faster deployments and reduced storage costs.
Health Checks
Add a health check to your Docker run command:Troubleshooting
Build Failures
If the build fails, check:- All build arguments are provided
- Network connectivity for npm install
- Sufficient disk space for build process
Container Won’t Start
Environment Variables Not Applied
Next Steps
Environment Variables
Configure application settings and API endpoints
Nginx Configuration
Customize web server settings and routing
