Skip to content

[codex] Use managed Redis and Postgres in Coolify compose#279

Open
michaelmwu wants to merge 1 commit into
mainfrom
michaelmwu/coolify-managed-infra
Open

[codex] Use managed Redis and Postgres in Coolify compose#279
michaelmwu wants to merge 1 commit into
mainfrom
michaelmwu/coolify-managed-infra

Conversation

@michaelmwu
Copy link
Copy Markdown
Member

@michaelmwu michaelmwu commented May 14, 2026

Description

Moves Redis and Postgres out of the canonical Coolify compose.yaml so production deploys use managed REDIS_URL and POSTGRES_URL runtime variables. Expands compose.local.yaml and the local Compose wrapper to keep Docker-managed Redis/Postgres for local development, including URL-encoded generated Postgres connection strings.

Related Issue

N/A

How Has This Been Tested?

Validated the local Compose wrapper, base Coolify compose config with managed Redis/Postgres URLs and no .env, required-variable failure without those URLs, reserved-character Postgres password encoding, and git diff --check.

Summary by CodeRabbit

  • Documentation

    • Clarified local vs. production deployment architecture, distinguishing base and local overlay configurations.
    • Updated development workflow documentation for Docker Compose usage and environment variable handling.
  • Chores

    • Enhanced database credential handling with URL encoding support for special characters.
    • Improved Docker Compose configuration separation between canonical base stack and local development overrides.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

This PR refactors the deployment architecture to separate the base application stack from local development infrastructure. Postgres credentials are now safely URL-encoded to prevent special characters from breaking connection strings. The compose files are split: compose.yaml becomes the production-ready base without redis/postgres services, while compose.local.yaml expands with full local container definitions. Services now rely on environment-provided REDIS_URL and POSTGRES_URL instead of hardcoded connections. Documentation clarifies how Coolify provides managed infrastructure URLs in production while the local wrapper injects Docker-network URLs for development.

Changes

Compose Architecture and Credential Handling

Layer / File(s) Summary
Postgres credential URL-encoding
scripts/dev.sh, scripts/docker-compose.sh
New url_quote() helper functions safely URL-encode Postgres username, password, and database name before constructing POSTGRES_URL, preventing special characters from breaking the connection string in both dev and docker-compose workflows.
Base compose file refactoring
compose.yaml
Remove redis and postgres service definitions; switch discord_bot, web, and worker to require REDIS_URL and POSTGRES_URL environment variables with strict validation; remove health-based startup dependencies and rely on external infrastructure provision.
Local overlay compose expansion
compose.local.yaml
Expand redis and postgres with full image definitions, healthchecks, persistent volumes, and environment configuration; configure discord_bot, web, and worker to wait for local Redis/Postgres health via depends_on; declare named volumes for data persistence.
Architecture and configuration documentation
.env.example, README.md, DEVELOPMENT.md, AGENTS.md, ENVIRONMENT.md
Clarify the separation of compose.yaml (canonical base stack for Coolify) from compose.local.yaml (local Redis/Postgres overlay); document how managed URLs are provided by Coolify in production versus injected by the wrapper in local development; explain credential URL-encoding requirements.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A rabbit hops through Docker files with glee,
Separating base from local symphony,
URLs encoded, credentials kept safe,
Compose stacks now fit the deployment chaff! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing Redis and Postgres from compose.yaml and using managed versions via environment variables for Coolify deployments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch michaelmwu/coolify-managed-infra

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@michaelmwu michaelmwu marked this pull request as ready for review May 14, 2026 14:45
Copilot AI review requested due to automatic review settings May 14, 2026 14:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates deployment configuration so production Coolify uses managed Redis/Postgres URLs while local development keeps Docker-managed Redis/Postgres through the local Compose wrapper.

Changes:

  • Removes Redis/Postgres containers from base compose.yaml and requires managed REDIS_URL/POSTGRES_URL.
  • Moves local Redis/Postgres services into compose.local.yaml.
  • Updates local scripts and documentation for generated, URL-encoded Postgres DSNs.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
compose.yaml Converts the base app stack to require external Redis/Postgres URLs.
compose.local.yaml Adds local Redis/Postgres services and local app overrides.
scripts/docker-compose.sh Generates local Compose service URLs for Redis/Postgres.
scripts/dev.sh Generates host-run service URLs with encoded Postgres credentials.
README.md Documents managed production URLs and local Compose behavior.
ENVIRONMENT.md Updates environment variable guidance for managed/local URLs.
DEVELOPMENT.md Updates local development and Compose guidance.
AGENTS.md Updates agent-facing Compose architecture notes.
.env.example Adds guidance for URL-encoding Postgres credentials.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/docker-compose.sh
Comment on lines +10 to +15
python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$1"
}

POSTGRES_USER_ENC=$(url_quote "$POSTGRES_USER")
POSTGRES_PASSWORD_ENC=$(url_quote "$POSTGRES_PASSWORD")
POSTGRES_DB_ENC=$(url_quote "$POSTGRES_DB")
Comment thread scripts/dev.sh
}

POSTGRES_USER_ENC=$(url_quote "$POSTGRES_USER")
POSTGRES_PASSWORD_ENC=$(url_quote "$POSTGRES_PASSWORD")
Comment thread DEVELOPMENT.md
Use `.env.example` as source of truth. Key categories:

- Shared queue/runtime: `REDIS_URL`, `REDIS_QUEUE_NAME`, `POSTGRES_URL`, `JOB_MAX_ATTEMPTS`, `JOB_RETRY_BASE_SECONDS`, `JOB_RETRY_MAX_SECONDS`, `LOG_LEVEL`, webhook settings. Local defaults target host-run services; `docker-compose.yml` injects Docker-network URLs for containerized runs.
- Shared queue/runtime: `REDIS_URL`, `REDIS_QUEUE_NAME`, `POSTGRES_URL`, `JOB_MAX_ATTEMPTS`, `JOB_RETRY_BASE_SECONDS`, `JOB_RETRY_MAX_SECONDS`, `LOG_LEVEL`, webhook settings. Local defaults target host-run services; `compose.local.yaml` injects Docker-network Redis/Postgres URLs for local containerized runs.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe48ae77bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread compose.local.yaml
Comment on lines +51 to +54
REDIS_URL: redis://redis:6379/0
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-workflows}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Override POSTGRES_URL in the local overlay

When compose.local.yaml is loaded directly with compose.yaml (for example by tools using the overlay rather than scripts/docker-compose.sh), Compose merges the environment maps, so the base POSTGRES_URL entry remains. With the .env.example default copied to .env, the web and worker containers keep postgresql://...@127.0.0.1:5432/... and fail to connect to the local postgres service even though this overlay starts and waits for it; the wrapper masks this by exporting a Docker-network URL, but the overlay itself should also override POSTGRES_URL like it does for Redis.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
scripts/docker-compose.sh (1)

25-25: ⚡ Quick win

Remove unused individual Postgres credential variables from compose.local.yaml.

The application only uses POSTGRES_URL (referenced in apps/worker/src/five08/worker/migrations/env.py), not the individual POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB variables. Remove these from compose.local.yaml to eliminate configuration clutter and avoid maintenance issues from accidental divergence between the URL-encoded and raw credential forms.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/docker-compose.sh` at line 25, The compose file sets POSTGRES_URL and
also exports individual credential vars (POSTGRES_USER, POSTGRES_PASSWORD,
POSTGRES_DB / their _ENC variants) which are unused; remove the individual
Postgres credential variables from compose.local.yaml so only POSTGRES_URL
remains, and verify that the application (see env.py usage of POSTGRES_URL)
still works with the URL-only config and no references to
POSTGRES_USER/POSTGRES_PASSWORD/POSTGRES_DB remain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/docker-compose.sh`:
- Line 25: The compose file sets POSTGRES_URL and also exports individual
credential vars (POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB / their _ENC
variants) which are unused; remove the individual Postgres credential variables
from compose.local.yaml so only POSTGRES_URL remains, and verify that the
application (see env.py usage of POSTGRES_URL) still works with the URL-only
config and no references to POSTGRES_USER/POSTGRES_PASSWORD/POSTGRES_DB remain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5153ff47-536d-4ad8-a67e-0d21d6d34937

📥 Commits

Reviewing files that changed from the base of the PR and between a767be2 and fe48ae7.

📒 Files selected for processing (9)
  • .env.example
  • AGENTS.md
  • DEVELOPMENT.md
  • ENVIRONMENT.md
  • README.md
  • compose.local.yaml
  • compose.yaml
  • scripts/dev.sh
  • scripts/docker-compose.sh

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.

2 participants