Go to file
Tortue Torche bdf3aecd5e Use 'docker:20-dind' image for GitLab CI, for better reliability
Instead of the 'docker:dind', which use the 'stable' version of Docker
2021-11-30 18:01:51 +01:00
docs Fix documentation scrolling between pages 2021-11-25 17:54:43 +01:00
scripts Replace 'master' by 'main' git branch name in scripts 2021-11-30 17:58:56 +01:00
tests Add Windows support, but it could be unstable ⚠️ 2021-09-23 18:27:18 +02:00
.gitignore Experimental support for Portainer CE 2.0 & 2.1 2021-02-19 11:55:56 +01:00
.gitlab-ci.yml Use 'docker:20-dind' image for GitLab CI, for better reliability 2021-11-30 18:01:51 +01:00
CHANGELOG.md Replace 'master' by 'main' git branch name in scripts 2021-11-30 17:58:56 +01:00
Dockerfile Docker images are now multi-architecture 2021-11-30 17:52:51 +01:00
Dockerfile.core Docker images are now multi-architecture 2021-11-30 17:52:51 +01:00
Dockerfile.debian Docker images are now multi-architecture 2021-11-30 17:52:51 +01:00
Dockerfile.debian-core Docker images are now multi-architecture 2021-11-30 17:52:51 +01:00
LICENSE Add license 2018-11-21 15:12:03 -05:00
psu Add Windows support, but it could be unstable ⚠️ 2021-09-23 18:27:18 +02:00
README.md Test PSU with Portainer CE 2.9.3 2021-11-25 18:16:11 +01:00

Portainer Stack Utils

How to install

Standalone

Note

: The easiest way to install psu is to use Docker method, instead of this one

Check the Requirements section then git clone the repo and use the bash script below:

git clone https://gitlab.com/psuapp/psu.git
cd psu/
# Allow the 'psu' command to run everywhere:
export PATH="$(pwd):$PATH"
# Or if you want it permanent, with a super user account, run:
# ln -s $(pwd)/psu /usr/local/bin
#
# Then you can use psu, e.g.
psu deploy ...

For detailed instructions, see How to use section.

Requirements

You will need these dependencies installed:

Linux based systems (Alpine, Debian, Ubuntu...)
  • bash* (>= 4.4.23)
  • curl* (>= 7.64.0, but >= 7.76.0 is recommended)
  • jq* (>= 1.5.1)
  • uuidgen recommended only for some OS (Alpine and Debian work fine without it)

For Debian and similar apt-powered Linux systems, run: apt install bash curl jq

macOS

You should install Homebrew, then run: brew install bash coreutils jq

Windows
  • bash* (>= 4.4.23)
  • curl* (>= 7.64.0, but >= 7.76.0 is recommended)
  • jq* (>= 1.5.1)

Note

: psushould work with Windows, but it could be unstable ⚠️

You should download and install Git and jq for Windows

For all systems
  • docker-compose is recommended but not required (useful for linting docker compose/stack files)

* = required

Docker image and variants

If you don't want or can't install psu and its dependencies, you can run it with the default published Docker image, like this:

docker run psuapp/psu:1.2 deploy ...

Note

: Docker images are also available on GitLab.

For detailed instructions, see How to use section.

Supported tags

Published Docker images are tagged matching GitLab tags:

Variants

The core variant doesn't include docker-compose, so it's a bit smaller. But you can't lint Docker compose/stack file before deploying a stack.

  • 1-core, 1.2-core, 1.2.0-core -> v1.2.0
  • 1.1-core, 1.1.0-core -> v1.1.0
  • 1.0-core, 1.0.7-core -> v1.0.7

The debian and debian-core variants use Debian instead of Alpine as base image for psu.

  • 1-debian, 1.2-debian, 1.2.0-debian -> v1.2.0
  • 1-debian-core, 1.2-debian-core, 1.2.0-debian-core -> v1.2.0
  • 1.1-debian, 1.1.0-debian -> v1.1.0
  • 1.1-debian-core, 1.1.0-debian-core -> v1.1.0
  • 1.0-debian, 1.0.7-debian -> v1.0.7
  • 1.0-debian-core, 1.0.7-debian-core -> v1.0.7

Testing/debugging:

For testing/debugging, you can use this Docker image in interactive mode, to run any commands inside the container:

docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -it --rm --entrypoint bash psuapp/psu:1.2
# Run any commands here! E.g.
$ psu --version
Portainer Stack Utils, version 1.3.0-alpha
  License GPLv3: GNU GPL version 3

How to use

The provided psu script allows to deploy/update/remove... Portainer stacks. Settings can be passed through envvars and/or options and/or flags. Both envvars, options and flags can be mixed but options or flags will always overwrite envvar values. When deploying a stack, if it doesn't exist a new one is created, otherwise it's updated (unless strict mode is active).

With options

This is more suitable for standalone script usage.

  • <action> ("deploy", "rm", "ls"..., required): Whether to deploy, remove, list... the stack, not an option but an argument
  • --user (string, required): Username
  • --password (string, required): Password
  • --url (string, required): URL to Portainer
  • --name (string, required): Stack name
  • --compose-file (string, required if action=deploy): Path to docker-compose file

For detailed instructions, see the full options list.

Examples

psu deploy --user admin --password password --url https://portainer.local --name mystack --compose-file /path/to/docker-compose.yml --env-file /path/to/env_vars_file
psu rm --user admin --password password --url https://portainer.local --name mystack

With Docker:

docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env psuapp/psu:1.2 deploy --user admin --password password --url https://portainer.local --name mystack --compose-file docker-compose.yml --env-file .env

With flags

This is more suitable for standalone script usage.

  • <action> ("deploy", "rm", "ls"..., required): Whether to deploy, remove, list... the stack, not a flag but an argument
  • -u (string, required): Username
  • -p (string, required): Password
  • -l (string, required): URL to Portainer
  • -n (string, required): Stack name
  • -c (string, required if action=deploy): Path to docker-compose file

For detailed instructions, see the full flags list.

Examples

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

With Docker:

docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env psuapp/psu:1.2 deploy -u admin -p password -l https://portainer.local -n mystack -c docker-compose.yml -g .env

With envvars

This is particularly useful for CI/CD pipelines using Docker containers.

  • ACTION ("deploy", "rm", "ls"..., required): Whether to deploy, remove, list... the stack
  • PORTAINER_USER (string, required): Username
  • PORTAINER_PASSWORD (string, required): Password
  • PORTAINER_URL (string, required): URL to Portainer
  • PORTAINER_STACK_NAME (string, required): Stack name
  • DOCKER_COMPOSE_FILE (string, required if action=deploy): Path to docker-compose file

For detailed instructions, see the full envvars list.

Examples

export ACTION="deploy"
export PORTAINER_USER="admin"
export PORTAINER_PASSWORD="password"
export PORTAINER_URL="https://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
export ACTION="rm"
export PORTAINER_USER="admin"
export PORTAINER_PASSWORD="password"
export PORTAINER_URL="https://portainer.local"
export PORTAINER_STACK_NAME="mystack"

psu

With Docker:

docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env -e ACTION="deploy" -e PORTAINER_USER="admin" -e PORTAINER_PASSWORD="password" -e PORTAINER_URL="https://portainer.local" -e PORTAINER_STACK_NAME="mystack" -e DOCKER_COMPOSE_FILE="docker-compose.yml" -e ENVIRONMENT_VARIABLES_FILE=".env" psuapp/psu:1.2

Documentation

For advanced usage, see the full PSU documentation.

For detailed instructions, see the CLI Commands documentation.

Supported Portainer API

PSU was created for the latest versions of Portainer API, which at the time of writing are 1.24.2, 2.5.1, 2.6.3 and 2.9.3.

License

Source code contained by this project is licensed under the GNU General Public License version 3.

See LICENSE file for reference.