Skip to content

Add custom stack environment variables

Tortue Torche requested to merge github/fork/tortuetorche/patch-1 into master

Prior to this pull request psu script act like this: Stack env vars are set in the deploy() function. When a new stack is deployed it gets no env vars, and when an existing one is updated its envvars are reused (extracted from its stack definition into the stack_envvars variable and set back again).

For the first case this pull request load the content of the env vars file and transform it into JSON using a jq command and set it as the stack_envvars value. For the second case, though, the script update the current stack env vars rather than setting them from scratch, keeping any value not previously set in the env file.

The environment variables file path is customizable with the environment variable $ENVIRONMENT_VARIABLES_FILE like this:

export ACTION="deploy"
export PORTAINER_USER="admin"
export PORTAINER_PASSWORD="password"
export PORTAINER_URL="http://portainer.local"
export PORTAINER_STACK_NAME="mystack"
export DOCKER_COMPOSE_FILE="/path/to/docker-compose.yml"
export ENVIRONMENT_VARIABLES_FILE="/path/to/env_vars_file"

./psu

Or with the -g flag:

./psu -a deploy -u admin -p password -l http://portainer.local -n mystack -c /path/to/docker-compose.yml -g /path/to/env_vars_file

close #7 (closed)

Merge request reports