diff --git a/docs/docs/documentation/getting-started/installation/backend-config.md b/docs/docs/documentation/getting-started/installation/backend-config.md index 0f5c27d7a882..e9e8ce26ceaf 100644 --- a/docs/docs/documentation/getting-started/installation/backend-config.md +++ b/docs/docs/documentation/getting-started/installation/backend-config.md @@ -35,6 +35,7 @@ | POSTGRES_SERVER | postgres | Postgres database server address | | POSTGRES_PORT | 5432 | Postgres database port | | POSTGRES_DB | mealie | Postgres database name | +| POSTGRES_URL_OVERRIDE | None | Optional Postgres URL override to use instead of POSTGRES_* variables | ### Email diff --git a/docs/docs/documentation/getting-started/installation/postgres.md b/docs/docs/documentation/getting-started/installation/postgres.md index 30ba1e86a3bd..0b9d1b1a2dbc 100644 --- a/docs/docs/documentation/getting-started/installation/postgres.md +++ b/docs/docs/documentation/getting-started/installation/postgres.md @@ -5,40 +5,39 @@ PostgreSQL might be considered if you need to support many concurrent users. In **For Environment Variable Configuration, see** [Backend Configuration](./backend-config.md) ```yaml ---- -version: "3.7" services: mealie: image: ghcr.io/mealie-recipes/mealie:v1.4.0 # (3) container_name: mealie + restart: always ports: - "9925:9000" # (1) deploy: resources: limits: memory: 1000M # (2) - depends_on: - - postgres volumes: - mealie-data:/app/data/ environment: - # Set Backend ENV Variables Here - - ALLOW_SIGNUP=true - - PUID=1000 - - PGID=1000 - - TZ=America/Anchorage - - MAX_WORKERS=1 - - WEB_CONCURRENCY=1 - - BASE_URL=https://mealie.yourdomain.com + # Set Backend ENV Variables Here + ALLOW_SIGNUP: true + PUID: 1000 + PGID: 1000 + TZ: America/Anchorage + MAX_WORKERS: 1 + WEB_CONCURRENCY: 1 + BASE_URL: https://mealie.yourdomain.com + # Database Settings + DB_ENGINE: postgres + POSTGRES_USER: mealie + POSTGRES_PASSWORD: mealie + POSTGRES_SERVER: postgres + POSTGRES_PORT: 5432 + POSTGRES_DB: mealie + depends_on: + postgres: + condition: service_healthy - # Database Settings - - DB_ENGINE=postgres - - POSTGRES_USER=mealie - - POSTGRES_PASSWORD=mealie - - POSTGRES_SERVER=postgres - - POSTGRES_PORT=5432 - - POSTGRES_DB=mealie - restart: always postgres: container_name: postgres image: postgres:15 @@ -48,12 +47,15 @@ services: environment: POSTGRES_PASSWORD: mealie POSTGRES_USER: mealie + healthcheck: + test: ["CMD", "pg_isready"] + interval: 30s + timeout: 20s + retries: 3 volumes: mealie-data: - driver: local mealie-pgdata: - driver: local ``` diff --git a/docs/docs/documentation/getting-started/installation/sqlite.md b/docs/docs/documentation/getting-started/installation/sqlite.md index 057e8743684c..d9ff176309cb 100644 --- a/docs/docs/documentation/getting-started/installation/sqlite.md +++ b/docs/docs/documentation/getting-started/installation/sqlite.md @@ -9,12 +9,11 @@ SQLite is a popular, open source, self-contained, zero-configuration database th **For Environment Variable Configuration, see** [Backend Configuration](./backend-config.md) ```yaml ---- -version: "3.7" services: mealie: image: ghcr.io/mealie-recipes/mealie:v1.4.0 # (3) container_name: mealie + restart: always ports: - "9925:9000" # (1) deploy: @@ -24,19 +23,17 @@ services: volumes: - mealie-data:/app/data/ environment: - # Set Backend ENV Variables Here - - ALLOW_SIGNUP=true - - PUID=1000 - - PGID=1000 - - TZ=America/Anchorage - - MAX_WORKERS=1 - - WEB_CONCURRENCY=1 - - BASE_URL=https://mealie.yourdomain.com - restart: always + # Set Backend ENV Variables Here + ALLOW_SIGNUP: true + PUID: 1000 + PGID: 1000 + TZ: America/Anchorage + MAX_WORKERS: 1 + WEB_CONCURRENCY: 1 + BASE_URL: https://mealie.yourdomain.com volumes: mealie-data: - driver: local ``` diff --git a/mealie/core/settings/db_providers.py b/mealie/core/settings/db_providers.py index 9cd1a5aea101..383ac50dc3bf 100644 --- a/mealie/core/settings/db_providers.py +++ b/mealie/core/settings/db_providers.py @@ -39,18 +39,25 @@ class PostgresProvider(AbstractDBProvider, BaseSettings): POSTGRES_SERVER: str = "postgres" POSTGRES_PORT: str = "5432" POSTGRES_DB: str = "mealie" + POSTGRES_URL_OVERRIDE: str | None = None model_config = SettingsConfigDict(arbitrary_types_allowed=True, extra="allow") @property def db_url(self) -> str: - host = f"{self.POSTGRES_SERVER}:{self.POSTGRES_PORT}" + if self.POSTGRES_URL_OVERRIDE: + url = PostgresDsn(url=self.POSTGRES_URL_OVERRIDE) + if not url.scheme == ("postgresql"): + raise ValueError("POSTGRES_URL_OVERRIDE scheme must be postgresql") + + return str(url) + return str( PostgresDsn.build( scheme="postgresql", username=self.POSTGRES_USER, password=urlparse.quote_plus(self.POSTGRES_PASSWORD), - host=host, + host=f"{self.POSTGRES_SERVER}:{self.POSTGRES_PORT}", path=f"{self.POSTGRES_DB or ''}", ) )