diff --git a/.env b/.env index 40f9d76..7e47048 100644 --- a/.env +++ b/.env @@ -26,6 +26,7 @@ SMTP_PORT=587 # Postgres POSTGRES_SERVER=localhost +POSTGRES_PORT=5432 POSTGRES_DB=app POSTGRES_USER=postgres POSTGRES_PASSWORD=changethis diff --git a/backend/app/alembic/env.py b/backend/app/alembic/env.py index c146cf6..926f119 100755 --- a/backend/app/alembic/env.py +++ b/backend/app/alembic/env.py @@ -32,8 +32,9 @@ def get_url(): user = os.getenv("POSTGRES_USER", "postgres") password = os.getenv("POSTGRES_PASSWORD", "") server = os.getenv("POSTGRES_SERVER", "db") + port = os.getenv("POSTGRES_PORT", "5432") db = os.getenv("POSTGRES_DB", "app") - return f"postgresql+psycopg://{user}:{password}@{server}/{db}" + return f"postgresql+psycopg://{user}:{password}@{server}:{port}/{db}" def run_migrations_offline(): diff --git a/backend/app/core/config.py b/backend/app/core/config.py index 060090f..56d09ee 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -48,6 +48,7 @@ class Settings(BaseSettings): PROJECT_NAME: str SENTRY_DSN: HttpUrl | None = None POSTGRES_SERVER: str + POSTGRES_PORT: int = 5432 POSTGRES_USER: str POSTGRES_PASSWORD: str POSTGRES_DB: str = "" @@ -60,6 +61,7 @@ class Settings(BaseSettings): username=self.POSTGRES_USER, password=self.POSTGRES_PASSWORD, host=self.POSTGRES_SERVER, + port=self.POSTGRES_PORT, path=self.POSTGRES_DB, ) diff --git a/deployment.md b/deployment.md index b170a73..4ea39eb 100644 --- a/deployment.md +++ b/deployment.md @@ -137,6 +137,7 @@ You can set several variables, like: * `SMTP_PASSWORD`: The SMTP server password to send emails. * `EMAILS_FROM_EMAIL`: The email account to send emails from. * `POSTGRES_SERVER`: The hostname of the PostgreSQL server. You can leave the default of `db`, provided by the same Docker Compose. You normally wouldn't need to change this unless you are using a third-party provider. +* `POSTGRES_PORT`: The port of the PostgreSQL server. You can leave the default. You normally wouldn't need to change this unless you are using a third-party provider. * `POSTGRES_PASSWORD`: The Postgres password. * `POSTGRES_USER`: The Postgres user, you can leave the default. * `POSTGRES_DB`: The database name to use for this application. You can leave the default of `app`. diff --git a/docker-compose.yml b/docker-compose.yml index 50818fc..fe3eab3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -100,6 +100,7 @@ services: - SMTP_PASSWORD=${SMTP_PASSWORD} - EMAILS_FROM_EMAIL=${EMAILS_FROM_EMAIL} - POSTGRES_SERVER=db + - POSTGRES_PORT=${POSTGRES_PORT} - POSTGRES_DB=${POSTGRES_DB} - POSTGRES_USER=${POSTGRES_USER?Variable not set} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}