Add support for Docker secrets

This commit is contained in:
Dominik 2020-01-08 13:05:23 +01:00
parent c72fdd1fa8
commit a347f39c1b
3 changed files with 36 additions and 5 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
idrac_host.txt
idrac_password.txt
idrac_user.txt
idrac_port.txt

View File

@ -1,4 +1,4 @@
version: '2' version: '3.1'
services: services:
idrac1: idrac1:
@ -21,11 +21,18 @@ services:
ports: ports:
- 5801:5800 - 5801:5800
- 5901:5900 - 5901:5900
environment: secrets:
- IDRAC_HOST=idrac2.example.org - idrac_host
- IDRAC_USER=root - idrac_user
- IDRAC_PASSWORD=1234 - idrac_password
volumes: volumes:
- /path/to/app:/app - /path/to/app:/app
- /path/to/media:/vmedia - /path/to/media:/vmedia
- /path/to/screenshots:/screenshots - /path/to/screenshots:/screenshots
secrets:
idrac_host:
file: ./idrac_host.txt
idrac_user:
file: ./idrac_user.txt
idrac_password:
file: ./idrac_password.txt

View File

@ -6,6 +6,26 @@ NC='\033[0m'
echo "Starting" echo "Starting"
if [ -f "/run/secrets/idrac_host" ]; then
echo "Using Docker secret for IDRAC_HOST"
IDRAC_HOST="$(cat /run/secrets/idrac_host)"
fi
if [ -f "/run/secrets/idrac_port" ]; then
echo "Using Docker secret for IDRAC_PORT"
IDRAC_PORT="$(cat /run/secrets/idrac_port)"
fi
if [ -f "/run/secrets/idrac_user" ]; then
echo "Using Docker secret for IDRAC_USER"
IDRAC_USER="$(cat /run/secrets/idrac_user)"
fi
if [ -f "/run/secrets/idrac_password" ]; then
echo "Using Docker secret for IDRAC_PASSWORD"
IDRAC_PASSWORD="$(cat /run/secrets/idrac_password)"
fi
if [ -z "${IDRAC_HOST}" ]; then if [ -z "${IDRAC_HOST}" ]; then
echo "${RED}Please set a proper idrac host with IDRAC_HOST${NC}" echo "${RED}Please set a proper idrac host with IDRAC_HOST${NC}"
sleep 2 sleep 2