I have my package-based docker container based on the univention/ucs-appbox-amd64:4.2-2 image up and running. My app is started - as suggested - via a systemd service unit.
The app fails to start up, because it is missing the environment variables (DB_HOST, DB_PASSWORD, DB_NAME and so on) to connect to the host’s mysql database. I’ve dump a list of the environment during the application’s startup:
Mar 06 15:27:30 kitom-23801244 bash[8569]: environ({‘PATH’: ‘/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin’, ‘LANG’: ‘C.UTF-8’, ‘KITOMA_CONFIG’: ‘/opt/kitoma/config/default.py’, ‘FLASK_APP’: ‘kitoma’, ‘_’: ‘/opt/kitoma/bin/python3.4’, ‘PWD’: ‘/opt/kitoma’, ‘KITOMA_MODE’: ‘WEB’, ‘SHLVL’: ‘1’, ‘PYTHONPATH’: ‘/opt/kitoma/’})
The set variables are configured in the systemd unit:
[Unit]
Description=Kitoma VOIP-Management
[Service]
User=kitoma
Environment=PYTHONPATH=/opt/kitoma/
Environment=FLASK_APP=kitoma
Environment=LANG=C.UTF-8
Environment=KITOMA_CONFIG=/opt/kitoma/config/default.py
Environment=KITOMA_MODE=WEB
WorkingDirectory=/opt/kitoma/
ExecStart=/opt/kitoma/bin/python3.4 -m flask run --host 0.0.0.0
[Install]
WantedBy=multi-user.target
Please note that the required environment variables are available when I run the application manually from the bash console. I also tried to set ExecStart to start with
/bin/bash -c "myapp"
but it did not change the behavior. At the moment I have no idea how to make sure that the environment variables are injected into the systemd unit’s context.