Added overrider to use docker secrets for mariadb password

This commit is contained in:
daniel.radl
2025-07-01 16:16:53 +02:00
parent 80aa2bbd4f
commit f9170607f2
4 changed files with 21 additions and 2 deletions

View File

@@ -25,6 +25,10 @@ Frappe framework release. You can find all releases [here](https://github.com/fr
Password for MariaDB (or Postgres) database. Password for MariaDB (or Postgres) database.
### `DB_PASSWORD_SECRETS_FILE`
Path to the db_password.txt file. Set only if you use docker secrets for the database password (use `overrides/compose.mariadb-secrets.yaml`)
### `DB_HOST` ### `DB_HOST`
Hostname for MariaDB (or Postgres) database. Set only if external service for database is used or the container can not be reached by its service name (db) by other containers. Hostname for MariaDB (or Postgres) database. Set only if external service for database is used or the container can not be reached by its service name (db) by other containers.

View File

@@ -4,6 +4,9 @@ ERPNEXT_VERSION=v15.67.0
DB_PASSWORD=123 DB_PASSWORD=123
#Only if you use docker secrets for the db password
DB_PASSWORD_SECRETS_FILE=
# Only if you use external database # Only if you use external database
DB_HOST= DB_HOST=
DB_PORT= DB_PORT=

View File

@@ -0,0 +1,12 @@
services:
db:
environment:
- MYSQL_ROOT_PASSWORD: /run/secrets/db_password
healthcheck:
test: mysqladmin ping -h localhost --password="$(cat /run/secrets/db_password)"
secrets:
- db_password
secrets:
db_password:
file: ${DB_PASSWORD_SECRETS_FILE:?No db secret file set}

View File

@@ -10,7 +10,7 @@ services:
db: db:
image: mariadb:10.6 image: mariadb:10.6
healthcheck: healthcheck:
test: mysqladmin ping -h localhost --password=${DB_PASSWORD} test: mysqladmin ping -h localhost --password=${DB_PASSWORD:-123}
interval: 1s interval: 1s
retries: 20 retries: 20
restart: unless-stopped restart: unless-stopped
@@ -20,7 +20,7 @@ services:
- --skip-character-set-client-handshake - --skip-character-set-client-handshake
- --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6 - --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6
environment: environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:?No db password set} MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-123}
volumes: volumes:
- db-data:/var/lib/mysql - db-data:/var/lib/mysql