Skip to content

Commit

Permalink
added loading KICKSECRETS_ from env
Browse files Browse the repository at this point in the history
  • Loading branch information
dermatthes committed Apr 28, 2020
1 parent 573b0e3 commit c7a1277
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ KICKSTART_PORTS="80:4200;25:25" # Change the Port-Mappings
KICKSTART_WIN_PATH= # If running on windows - map bash
```

## Secrets

Secrets can be added either via the command `kickstart secrets add <secretname>` or
via Environment variables (used for ci-builds). All variables names `KICKSECRET_name` will
be mounted to `/run/secrets/name`.


## Project-wide config file
Expand Down
4 changes: 2 additions & 2 deletions dist/.kick-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ services:
some_service:
image: some/image
networks:
- project_name
- dist


networks:
project_name:
dist:
external: true
## Very important: Otherwise no connection
14 changes: 14 additions & 0 deletions dist/kickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ elif [ -e "$PROGPATH/.env.dist" ] && [ "$#" == "0" ]; then
read -r -p "Hit (enter) to continue without .env file or CTRL-C to exit." choice
fi





run_container() {
echo -e $COLOR_GREEN"Loading container '$FROM_IMAGE'..."
if [ "$OFFLINE_MODE" == "0" ]
Expand Down Expand Up @@ -700,6 +704,16 @@ then
fi;


echo "Scanning env for KICKSECRET_*";
for secret in $(env | grep ^KICKSECRET | sed 's/KICKSECRET_\([a-zA-Z0-9_]\+\).*/\1/'); do
secretName="KICKSECRET_$secret"
secretFile="/tmp/.kicksecret.$secretName"
echo ${!secretName} > $secretFile
echo "+ adding secret from env: $secretName > /run/secrets/$secret";
DOCKER_OPT_PARAMS="$DOCKER_OPT_PARAMS -v '$secretFile:/run/secrets/$secret' "
done;


# Ports to be exposed
IFS=';' read -r -a _ports <<< "$KICKSTART_PORTS"
for _port in "${_ports[@]}"
Expand Down
10 changes: 10 additions & 0 deletions doc/secretadd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash


secretsEnv = $(env | grep ^KICKSECRET | sed 's/KICKSECRET_\([a-zA-Z0-9_]\+\).*/\1/');
for secret in $(env | grep ^KICKSECRET | sed 's/KICKSECRET_\([a-zA-Z0-9_]\+\).*/\1/'); do
secretName="KICKSECRET_$secret"
echo ${!secretName} > "/tmp/.kicksecret.$secretName"

echo "adding secret $secret: ${!secretName}";
done;

0 comments on commit c7a1277

Please sign in to comment.