Skip to content

Commit

Permalink
Merge pull request #22 from DomiStyle/docker-secrets
Browse files Browse the repository at this point in the history
Add support for Docker secrets
  • Loading branch information
DomiStyle authored Jan 13, 2020
2 parents c72fdd1 + a347f39 commit 9c4bd7a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
idrac_host.txt
idrac_password.txt
idrac_user.txt
idrac_port.txt
17 changes: 12 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2'
version: '3.1'

services:
idrac1:
Expand All @@ -21,11 +21,18 @@ services:
ports:
- 5801:5800
- 5901:5900
environment:
- IDRAC_HOST=idrac2.example.org
- IDRAC_USER=root
- IDRAC_PASSWORD=1234
secrets:
- idrac_host
- idrac_user
- idrac_password
volumes:
- /path/to/app:/app
- /path/to/media:/vmedia
- /path/to/screenshots:/screenshots
secrets:
idrac_host:
file: ./idrac_host.txt
idrac_user:
file: ./idrac_user.txt
idrac_password:
file: ./idrac_password.txt
20 changes: 20 additions & 0 deletions startapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ NC='\033[0m'

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
echo "${RED}Please set a proper idrac host with IDRAC_HOST${NC}"
sleep 2
Expand Down

0 comments on commit 9c4bd7a

Please sign in to comment.