Skip to content

Improve Docker Compose setup with environment variables and health checks#3

Merged
peteralcock merged 1 commit intomainfrom
claude/add-docker-compose-lyRLb
Jan 31, 2026
Merged

Improve Docker Compose setup with environment variables and health checks#3
peteralcock merged 1 commit intomainfrom
claude/add-docker-compose-lyRLb

Conversation

@peteralcock
Copy link
Owner

Summary

This PR significantly improves the Docker Compose configuration and deployment setup for ZEPSEC (RISM) by adding environment variable support, comprehensive health checks, proper service dependencies, and an enhanced entrypoint script. The changes make the application more robust and production-ready.

Key Changes

  • Redis Configuration: Updated config/cable.yml to use environment variables (REDIS_HOST and REDIS_PORT) instead of hardcoded localhost values, allowing flexible deployment configurations.

  • Docker Compose Restructuring:

    • Upgraded to version 3.8 for better feature support
    • Introduced x-app-common anchor to reduce duplication across app and sidekiq services
    • Reorganized services with clear section comments for better readability
    • Added comprehensive health checks for all services (PostgreSQL, Redis, Rails app, Sidekiq, Nginx)
    • Implemented proper service dependency ordering using condition: service_healthy
    • Enabled Nginx reverse proxy (previously commented out) for production-like setup
    • Improved volume naming (removed rism_ prefix for cleaner organization)
    • Added restart: unless-stopped policy for all services
    • Enhanced Redis configuration with AOF persistence
  • Rails Entrypoint Script Enhancement:

    • Added PostgreSQL readiness check with configurable host/port/user via environment variables
    • Implemented automatic database migration/setup on container start
    • Added informative logging for each startup step
    • Improved PID file cleanup with safer rm -f command
    • Changed to exec for proper signal handling
  • Documentation: Updated inline comments with clearer quick-start instructions and operational commands.

Notable Implementation Details

  • Health checks use appropriate timeouts and retry counts for each service type
  • Database migrations run automatically on app startup, eliminating manual setup steps
  • Service dependencies ensure proper startup order and readiness before dependent services start
  • Environment variable defaults maintain backward compatibility while allowing customization
  • Nginx is now enabled by default, providing a production-like reverse proxy setup

https://claude.ai/code/session_01UPcymGmBUdtTd33qSYF24Q

- Rewrite docker-compose.yml: build from Dockerfile instead of pre-built
  image, add YAML anchor for shared app config, enable nginx reverse
  proxy, fix sidekiq command, add health checks with dependency ordering,
  add restart policies, use init.sql for DB initialization
- Improve rails-entrypoint.sh: wait for PostgreSQL readiness before
  starting, auto-run migrations on boot, use exec for proper signal
  handling
- Fix config/cable.yml: use REDIS_HOST/REDIS_PORT env vars so
  ActionCable connects to the Redis container in Docker

Services: PostgreSQL, Redis, Rails (Puma), Sidekiq, Nginx

https://claude.ai/code/session_01UPcymGmBUdtTd33qSYF24Q
@peteralcock peteralcock merged commit d607a32 into main Jan 31, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants