Skip to content

fix(docker-compose-light): revert/light-compose and fix init scripts (examples & cy…#38492

Closed
bschreder wants to merge 1 commit intoapache:masterfrom
bschreder:fix/38491-docker-compose-light
Closed

fix(docker-compose-light): revert/light-compose and fix init scripts (examples & cy…#38492
bschreder wants to merge 1 commit intoapache:masterfrom
bschreder:fix/38491-docker-compose-light

Conversation

@bschreder
Copy link

@bschreder bschreder commented Mar 7, 2026

User description

…press init)

  • restore expected EXAMPLES env usage in docker-compose-light.yml
  • ensure psql uses -d "" in cypress-init.sh and examples-init.sh

SUMMARY

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Fixes #38491


CodeAnt-AI Description

Restore example DB init and expose light DB port in docker-compose-light

What Changed

  • Database initialization scripts now target the intended Postgres database explicitly, so example and Cypress databases are created against the configured POSTGRES_DB instead of relying on psql defaults
  • The light compose Postgres service now publishes the database port to the host (configurable via DATABASE_PORT), making the DB reachable from the host machine
  • Superset light services receive EXAMPLES_HOST and EXAMPLES_DB environment variables so example-data setup can connect to the correct database host and name

Impact

✅ Clearer example DB initialization
✅ Accessible local DB port for development
✅ Reliable test/example database creation

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

…press init)

- restore expected EXAMPLES env usage in docker-compose-light.yml
- ensure psql uses -d "" in cypress-init.sh and examples-init.sh
Copilot AI review requested due to automatic review settings March 7, 2026 21:14
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Mar 7, 2026

Code Review Agent Run #77a788

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 2d41e89..2d41e89
    • docker/docker-entrypoint-initdb.d/cypress-init.sh
    • docker/docker-entrypoint-initdb.d/examples-init.sh
  • Files skipped - 1
    • docker-compose-light.yml - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the install:docker Installation - docker container label Mar 7, 2026
@codeant-ai-for-open-source codeant-ai-for-open-source bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Mar 7, 2026
set -e

psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" <<-EOSQL
psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" -d "${POSTGRES_DB}" <<-EOSQL
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Environment variables for database user, password, and name are interpolated directly into SQL without proper quoting/escaping, so if they contain quotes or special characters the SQL will break or could be leveraged for SQL injection; instead, escape dangerous characters in the shell and use quoted identifiers/strings in the SQL. [security]

Severity Level: Major ⚠️
- ❌ Examples database initialization fails with quoted EXAMPLES_* values.
- ⚠️ Docker-compose-light demo may start without examples database.
- ⚠️ SQL injection risk if environment variables externally controlled.

Copy link
Contributor

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 fixes docker-compose-light example DB initialization by restoring the expected EXAMPLES_* environment wiring and ensuring Postgres init scripts connect to an explicit database during bootstrap.

Changes:

  • Update Postgres init scripts to run psql against POSTGRES_DB to avoid default-DB connection failures.
  • Override EXAMPLES_HOST/EXAMPLES_DB in docker-compose-light.yml so examples loading targets db-light.
  • Publish the db-light Postgres port to the host (parameterized via DATABASE_PORT).

Reviewed changes

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

File Description
docker/docker-entrypoint-initdb.d/examples-init.sh Connect psql to POSTGRES_DB so user/db creation runs reliably in light compose.
docker/docker-entrypoint-initdb.d/cypress-init.sh Connect psql to POSTGRES_DB so cypress DB creation runs reliably in light compose.
docker-compose-light.yml Fix examples DB host/db env overrides; add host port publishing for db-light.

image: postgres:17
restart: unless-stopped
ports:
- "${DATABASE_PORT:-5432}:5432" # Parameterized port, accessible on all interfaces
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

db-light now publishes Postgres on all interfaces (no 127.0.0.1 bind). This is inconsistent with docker-compose.yml (which binds 127.0.0.1:${DATABASE_PORT:-5432}:5432) and can unintentionally expose the database when running on a shared/remote host. Consider binding to localhost (or making the bind address configurable) to keep the default safer.

Suggested change
- "${DATABASE_PORT:-5432}:5432" # Parameterized port, accessible on all interfaces
- "${DATABASE_BIND_ADDRESS:-127.0.0.1}:${DATABASE_PORT:-5432}:5432" # Bind Postgres to localhost by default

Copilot uses AI. Check for mistakes.
image: postgres:17
restart: unless-stopped
ports:
- "${DATABASE_PORT:-5432}:5432" # Parameterized port, accessible on all interfaces
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

Publishing the DB port using ${DATABASE_PORT} is potentially misleading here because DATABASE_PORT is also used by Superset to build its in-network SQLAlchemy URI (where db-light is still reachable on container port 5432 regardless of the published host port). If someone changes DATABASE_PORT to avoid a host port collision, Superset will likely try connecting to db-light:${DATABASE_PORT} and fail. Consider using a separate variable for the published host port (or hardcoding :5432 for container-to-container traffic and only parameterizing the host side).

Suggested change
- "${DATABASE_PORT:-5432}:5432" # Parameterized port, accessible on all interfaces
- "${HOST_DATABASE_PORT:-5432}:5432" # Host-published port; container always listens on 5432

Copilot uses AI. Check for mistakes.
@bschreder bschreder closed this Mar 8, 2026
@bschreder bschreder deleted the fix/38491-docker-compose-light branch March 8, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

install:docker Installation - docker container size/S size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker-compose-light: Examples DB init fails

2 participants