97 lines
3.7 KiB
YAML
97 lines
3.7 KiB
YAML
|
|
name: home-assistant
|
|
|
|
secrets:
|
|
home-assistant_postgresql_database:
|
|
file: ${SECRETSDIR}/home-assistant_postgresql_database
|
|
home-assistant_postgresql_password:
|
|
file: ${SECRETSDIR}/home-assistant_postgresql_password
|
|
home-assistant_postgresql_username:
|
|
file: ${SECRETSDIR}/home-assistant_postgresql_username
|
|
|
|
networks:
|
|
traefik-net:
|
|
external: true
|
|
postgres-net:
|
|
external: true
|
|
|
|
services:
|
|
home-assistant:
|
|
image: "ghcr.io/home-assistant/home-assistant:stable"
|
|
hostname: home-assistant
|
|
privileged: true
|
|
volumes:
|
|
- /etc/localtime:/etc/localtime:ro
|
|
- "${DATADIR}/config:/config"
|
|
- /run/dbus:/run/dbus:ro
|
|
restart: unless-stopped
|
|
env_file: .home-assistant.env
|
|
networks:
|
|
- traefik-net
|
|
- postgres-net
|
|
depends_on:
|
|
postgresql:
|
|
condition: service_healthy
|
|
labels:
|
|
- traefik.enable=true
|
|
- traefik.docker.network=traefik-net
|
|
# http middlewares
|
|
# ---------------------------
|
|
#- "traefik.http.middlewares.${APPLICATION_NAME}-auth.basicauth.users=${ADMIN_CREDENTIALS}, ${USER_CREDENTIALS}"
|
|
#- "traefik.http.middlewares.${APPLICATION_NAME}-auth.basicauth.usersfile=/mnt/users/common.txt"
|
|
- "traefik.http.middlewares.${APPLICATION_NAME}-https-redirect.redirectscheme.scheme=https"
|
|
- "traefik.http.middlewares.${APPLICATION_NAME}-https-redirect.redirectscheme.permanent=true"
|
|
#
|
|
# http services
|
|
# -------------
|
|
- "traefik.http.services.${APPLICATION_NAME}-svc.loadbalancer.server.port=${WEBUI_PORT}"
|
|
#
|
|
# http routers
|
|
# ------------
|
|
# limit router to web ":80" entrypoint
|
|
- "traefik.http.routers.${APPLICATION_NAME}-rtr.entrypoints=web"
|
|
# set match criteria for router
|
|
- "traefik.http.routers.${APPLICATION_NAME}-rtr.rule=Host(`${APPLICATION_NAME}.${DOMAINNAME}`)&& PathPrefix(`/`)"
|
|
# attach middlewares to router
|
|
- "traefik.http.routers.${APPLICATION_NAME}-rtr.middlewares=${APPLICATION_NAME}-https-redirect"
|
|
# assign svc target to router
|
|
- "traefik.http.routers.${APPLICATION_NAME}-rtr.service=${APPLICATION_NAME}-svc"
|
|
#
|
|
# limit router to websecure ":443" entrypoint
|
|
- "traefik.http.routers.${APPLICATION_NAME}-secure-rtr.entrypoints=websecure"
|
|
# set match criteria for router
|
|
- "traefik.http.routers.${APPLICATION_NAME}-secure-rtr.rule=Host(`${APPLICATION_NAME}.${DOMAINNAME}`)&& PathPrefix(`/`)"
|
|
# set router to be dedicated to secure requests only for the host specified in match criteria
|
|
- "traefik.http.routers.${APPLICATION_NAME}-secure-rtr.tls=true"
|
|
# generate certificates using following certresolver
|
|
- "traefik.http.routers.${APPLICATION_NAME}-secure-rtr.tls.certresolver=sthomeresolver"
|
|
# attach middlewares to router
|
|
#- "traefik.http.routers.${APPLICATION_NAME}-secure-rtr.middlewares=${APPLICATION_NAME}-auth"
|
|
# assign svc target to router
|
|
- "traefik.http.routers.${APPLICATION_NAME}-secure-rtr.service=${APPLICATION_NAME}-svc"
|
|
|
|
postgresql:
|
|
image: postgres:16-alpine
|
|
hostname: "${APPLICATION_NAME}_postgresql"
|
|
shm_size: 128mb # https://hub.docker.com/_/postgres
|
|
restart: unless-stopped
|
|
env_file: .postgresql.env
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
|
|
start_period: 20s
|
|
interval: 30s
|
|
retries: 5
|
|
timeout: 5s
|
|
networks:
|
|
postgres-net:
|
|
aliases: ["home-assistant_postgresql"]
|
|
secrets:
|
|
- home-assistant_postgresql_database
|
|
- home-assistant_postgresql_password
|
|
- home-assistant_postgresql_username
|
|
volumes:
|
|
- "${DATADIR}/pgdata:/var/lib/postgresql/data"
|
|
- "${DATADIR}/pgbackups:/mnt/backups"
|
|
|
|
|