services: homeassistant: container_name: home-assistant image: "ghcr.io/home-assistant/home-assistant:stable" volumes: - /path/to/home-assistant/config:/config - /etc/localtime:/etc/localtime:ro environment: - PUID=${PUID} - PGID=${PGID} - TZ=${TZ} restart: unless-stopped ports: - ${HTTP_PORT}:8123 depends_on: - homeassistant-db privileged: true homeassistant-db: image: docker.io/postgres:16.3 container_name: homeassistant-db restart: unless-stopped environment: - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_DB=${POSTGRES_DB} # ensure the database gets created correctly # https://github.com/matrix-org/synapse/blob/master/docs/postgres.md#set-up-database - POSTGRES_INITDB_ARGS=--encoding=UTF-8 volumes: - /path/to/home-assistant/schemas:/var/lib/postgresql/data security_opt: - no-new-privileges:true