Skip to content

Docker Integration

Jessica Chioma edited this page Jul 20, 2024 · 2 revisions

Docker Integration

Project Structure

  • Docker Directory: Integrated a docker directory within the root of the Remix.js application.
  • Subdirectories: Created separate subdirectories for development, staging, and production environments:
    • docker/development
    • docker/staging
    • docker/production

Docker Compose Configuration

Development Environment

  • docker/development/Dockerfile
  • docker/development/docker-compose.yml

Staging Environment

  • docker/staging/Dockerfile
  • docker/staging/docker-compose.yml

Production Environment

  • docker/prod/Dockerfile
  • docker/prod/docker-compose.yml

Container Management

  • Each docker-compose.yml file is configured to spin up two Docker containers for the frontend application, except for the staging environment, it only spins up one Docker container.
  • Running docker-compose up results in a total of five containers (two for development, one for staging, and two for production).
  • This setup ensures high availability by allowing updates to be applied to one container while the other continues to serve traffic, thus preventing downtime.
  • NGINX is configured for both load balancing and reverse proxying, ensuring efficient request routing and that no single container becomes overwhelmed.
  • A cron job is configured to automate the clearing of cache and deletion of unnecessary containers every two hours. The command that triggers the cron job is docker system prune -f. This ensures the server remains fast and does not experience lag or latency due to hoarded resources.

This comprehensive Docker setup enhances the reliability and performance of the Remix.js application in development, staging, and production environments.