Skip to content

Support overriding exposed database port numbmer #2840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

toby-griffiths
Copy link
Contributor

@toby-griffiths toby-griffiths commented Feb 3, 2025

This adds support to specify the DB_PORT env var in order to be able to override the exposed database service port number.

Q A
Branch? main
Tickets n/a
License MIT
Doc PR n/a

This just makes the database service's exposed port use the DB_PORT environment variable if provided.

This allows people running multiple Docker Postgres services on thier machine an easy way to provide a custom
port number to avoid conflicts with existing, running Postgres service containers.

I've not submitted a docs PR as I don't think that the Docker *_PORT env vars are currently included in the docs from a quick search.

I have not added a test for this yet, but please let me know if you need one and I'll try to work out how to add one.

I cannot see a CHANGELOG in this project root to update with this change, as instructed int he PR template.

This adds support to specify the DB_PORT env var in order to be able to override the exposed database service port number.
@toby-griffiths toby-griffiths force-pushed the support-db-port-env-var branch from 7f4ec44 to 6e78680 Compare February 3, 2025 10:01
@toby-griffiths toby-griffiths marked this pull request as ready for review February 3, 2025 10:41
@@ -37,7 +37,7 @@ services:
database:
ports:
- target: 5432
published: 5432
published: ${DB_PORT:-5432}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe DATABASE_PORT for consistency with DATABASE_URL?

By the way, we should also use this new variable in DATABASE_URL in .env, otherwise the user will have to also override DATABASE_URL.

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