Verified Commit 979cfd09 authored by Quentin Duchemin's avatar Quentin Duchemin
Browse files

Fix Python syntax and mount all config files

parent 21ceddeb
Pipeline #52624 failed with stages
......@@ -24,7 +24,7 @@ On copie `secrets/db.secrets.example` dans `secrets/db.secrets` :
* On assigne le nom de la VM à `HOSTNAME` (*e.g.* `pica02`),
* On renseigne les secrets (voir [plus bas]((#gestion-des-secrets)))
Docker Compose sélectionne automatiquement le bon fichier de configuration en fonction du nom d'hôte de la machine virtuelle, il n'y a donc rien à modifier :
L'outil sélectionne automatiquement le bon fichier de configuration en fonction du nom d'hôte de la machine virtuelle, il n'y a donc rien à modifier :
```
$ docker-compose up -d
......
......@@ -22,8 +22,8 @@ def add_value_to_key(value, key):
os.environ[key] = value
CONFIG_FOLDER = '/config'
CONFIG_FILE = 'backup_data.json'
PATH_TO_CONFIG = CONFIG_FOLDER + '/' + CONFIG_FILE
CONFIG_FILE = os.environ['HOSTNAME']
PATH_TO_CONFIG = CONFIG_FOLDER + '/' + CONFIG_FILE + '.json'
# Check if config file exists
if not(os.path.exists(CONFIG_FOLDER)):
......@@ -64,10 +64,12 @@ for service in services_list:
add_value_to_key(services_list[service]["Host"],"MYSQL_HOST_LIST")
add_value_to_key(services_list[service]["Port"],"MYSQL_PORT_LIST")
user = services_list[service]["User"]
user = os.environ[user] if user in os.environ
if user in os.environ:
user = os.environ[user]
add_value_to_key(user,"MYSQL_USER_LIST")
password = services_list[service]["Password"]
password = os.environ[password] if password in os.environ
if password in os.environ:
password = os.environ[password]
add_value_to_key(password,"MYSQL_PASS_LIST")
add_value_to_key(services_list[service]["Database"],"MYSQL_DB_LIST")
add_value_to_key(services_list[service]["Init-Backup"],"MYSQL_INIT_BACKUP_LIST")
......@@ -85,10 +87,12 @@ for service in services_list:
add_value_to_key(services_list[service]["Host"],"POSTGRES_HOST_LIST")
add_value_to_key(services_list[service]["Port"],"POSTGRES_PORT_LIST")
user = services_list[service]["User"]
user = os.environ[user] if user in os.environ
if user in os.environ:
user = os.environ[user]
add_value_to_key(user,"POSTGRES_USER_LIST")
password = services_list[service]["Password"]
password = os.environ[password] if password in os.environ
if password in os.environ:
password = os.environ[password]
add_value_to_key(password,"POSTGRES_PASS_LIST")
add_value_to_key(services_list[service]["Database"],"POSTGRES_DB_LIST")
add_value_to_key(services_list[service]["Init-Backup"],"POSTGRES_INIT_BACKUP_LIST")
......
......@@ -7,11 +7,11 @@ networks:
services:
db-backup:
image: registry.picasoft.net/pica-db-backup:1.1"
image: registry.picasoft.net/pica-db-backup:1.1
container_name: db-backup
volumes:
- /DATA/BACKUP/:/backup/
- ./config/${HOSTNAME}.json:/config/backup_data.json
- ./config:/config
- /etc/localtime:/etc/localtime:ro
env_file:
- ./secrets/db.secrets
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment