From 5dae122f53e7df426b5e222710ff33b3c9393e8b Mon Sep 17 00:00:00 2001 From: willemserruys Date: Sun, 20 Nov 2022 22:05:59 +0100 Subject: [PATCH] chore: add mariadb database --- .gitignore | 6 +++- .../home-assistant/configuration.yaml | 36 ++++++++++--------- home-server/.env | 14 ++++---- home-server/.env.mariadb | 5 +++ home-server/docker-compose.yml | 15 ++++---- home-server/readme.md | 8 +++++ 6 files changed, 54 insertions(+), 30 deletions(-) create mode 100644 home-server/.env.mariadb diff --git a/.gitignore b/.gitignore index 648554d..53607f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -.env.mariadb +# Environment files for docker composes +.env.production + +# Home assistant configuration file +configuration.production.yaml diff --git a/configurations/home-assistant/configuration.yaml b/configurations/home-assistant/configuration.yaml index 67751e5..b8d6b6c 100644 --- a/configurations/home-assistant/configuration.yaml +++ b/configurations/home-assistant/configuration.yaml @@ -1,16 +1,20 @@ -# Loads default set of integrations. Do not remove -# This was added to the homeAutomation repo. -default_config: - -# Text to speech -tts: - - platform: google_translate - -automation: !include automations.yaml -script: !include scripts.yaml -scene: !include scenes.yaml - -http: - use_x_forwarded_for: true - trusted_proxies: - - 10.55.8.1 +# Loads default set of integrations. Do not remove +# This was added to the homeAutomation repo. +# This is a sample configuration. Please create a configuration.production.yml for production use. +default_config: + +# Text to speech +tts: + - platform: google_translate + +automation: !include automations.yaml +script: !include scripts.yaml +scene: !include scenes.yaml + +http: + use_x_forwarded_for: true + trusted_proxies: + - 10.55.8.1 + + + diff --git a/home-server/.env b/home-server/.env index 14a4a53..62502c9 100644 --- a/home-server/.env +++ b/home-server/.env @@ -1,10 +1,10 @@ # General settings -INTERNAL_IP: localhost - -# Db-Specific settings -# Should be overridden with a .env.mariadb file. -MARIADB_ROOT_PASSWORD=test -MARIADB_USER=homeassistant -MARIADB_PASSWORD=homeassistant +INTERNAL_IP: 0.0.0.0 +# Maria DB settings +# For testing purposes only. Please create a .env.mariadb to overwrite these variables +MARIADB_ROOT_PASSWORD=testing +MARIADB_DATABASE=homeassistant +MARIADB_USER=homeassistant_user +MARIADB_PASSWORD=homeassistant_pw diff --git a/home-server/.env.mariadb b/home-server/.env.mariadb new file mode 100644 index 0000000..9a3bf70 --- /dev/null +++ b/home-server/.env.mariadb @@ -0,0 +1,5 @@ +MARIADB_ROOT_PASSWORD=testing + +MARIADB_DATABASE=homeassistant_2 +MARIADB_USER=homeassistant_user +MARIADB_PASSWORD=homeassistant_pw diff --git a/home-server/docker-compose.yml b/home-server/docker-compose.yml index ad97501..5231920 100644 --- a/home-server/docker-compose.yml +++ b/home-server/docker-compose.yml @@ -1,23 +1,26 @@ version: "3.9" services: db: - image: mariadb + image: mariadb:latest restart: unless-stopped ports: - - ${INTERNAL_IP}:3306:3306 + - 3306:3306 env_file: - # Override the mariadb-specific settings in a .env.mariadb file. - # You should create the .env.mariadb file yourself. - .env - - .env.mariadb + - .env.production + volumes: + - /home/willem/mariadb:/var/lib/mysql homeassistant: image: "ghcr.io/home-assistant/home-assistant:stable" ports: - ${INTERNAL_IP}:8123:8123 volumes: - /home/willem/homeassistant:/config - - /home/willem/repos/homeAutomation/configurations/home-assistant/configuration.yaml:/config/configuration.yaml + - /home/willem/repos/homeAutomation/configurations/home-assistant/configuration.production.yaml:/config/configuration.yaml restart: unless-stopped + env_file: + - .env + - .env.production syncthing: image: lscr.io/linuxserver/syncthing:latest container_name: syncthing diff --git a/home-server/readme.md b/home-server/readme.md index 62234be..66d284c 100644 --- a/home-server/readme.md +++ b/home-server/readme.md @@ -22,6 +22,14 @@ ln -s /usr/bin/resolvectl /usr/local/bin/resolvconf TODO add .sh script to start in production +## Tips + +When database credentials are not updated after docker restart, consider using + +```bash +docker compose rm db +``` + ## To Do