Skip to content

Commit a347f39

Browse files
author
Dominik
committed
Add support for Docker secrets
1 parent c72fdd1 commit a347f39

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
idrac_host.txt
2+
idrac_password.txt
3+
idrac_user.txt
4+
idrac_port.txt

docker-compose.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: '3.1'
22

33
services:
44
idrac1:
@@ -21,11 +21,18 @@ services:
2121
ports:
2222
- 5801:5800
2323
- 5901:5900
24-
environment:
25-
- IDRAC_HOST=idrac2.example.org
26-
- IDRAC_USER=root
27-
- IDRAC_PASSWORD=1234
24+
secrets:
25+
- idrac_host
26+
- idrac_user
27+
- idrac_password
2828
volumes:
2929
- /path/to/app:/app
3030
- /path/to/media:/vmedia
3131
- /path/to/screenshots:/screenshots
32+
secrets:
33+
idrac_host:
34+
file: ./idrac_host.txt
35+
idrac_user:
36+
file: ./idrac_user.txt
37+
idrac_password:
38+
file: ./idrac_password.txt

startapp.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ NC='\033[0m'
66

77
echo "Starting"
88

9+
if [ -f "/run/secrets/idrac_host" ]; then
10+
echo "Using Docker secret for IDRAC_HOST"
11+
IDRAC_HOST="$(cat /run/secrets/idrac_host)"
12+
fi
13+
14+
if [ -f "/run/secrets/idrac_port" ]; then
15+
echo "Using Docker secret for IDRAC_PORT"
16+
IDRAC_PORT="$(cat /run/secrets/idrac_port)"
17+
fi
18+
19+
if [ -f "/run/secrets/idrac_user" ]; then
20+
echo "Using Docker secret for IDRAC_USER"
21+
IDRAC_USER="$(cat /run/secrets/idrac_user)"
22+
fi
23+
24+
if [ -f "/run/secrets/idrac_password" ]; then
25+
echo "Using Docker secret for IDRAC_PASSWORD"
26+
IDRAC_PASSWORD="$(cat /run/secrets/idrac_password)"
27+
fi
28+
929
if [ -z "${IDRAC_HOST}" ]; then
1030
echo "${RED}Please set a proper idrac host with IDRAC_HOST${NC}"
1131
sleep 2

0 commit comments

Comments
 (0)