Bump psu version to 1.3.0

commit d7a4363fe5
Author: Tortue Torche <126358-tortuetorche@users.noreply.gitlab.com>
Date: Tue Dec 7 18:28:47 2021 +0100
This commit is contained in:
psu-bot 2021-12-07 17:33:35 +00:00
parent 7a593af8e4
commit 43cc27ad2e
13 changed files with 2036 additions and 0 deletions

View File

733
public/1-3-stable/README.md Normal file
View File

@ -0,0 +1,733 @@
<h1>
<div class="docsify-hidden">Portainer Stack Utils Docs</div>
<abbr title="command-line interface">CLI</abbr> Commands
</h1>
<div class="docsify-hidden">
<h2>Table of contents</h2>
<!-- Generated by https://github.com/mcpride/atom-mdtoc -->
<!-- MDTOC maxdepth:2 firsth1:2 numbering:0 flatten:0 bullets:1 updateOnSave:1 -->
- [Available actions](#available-actions)
- [Aliased actions](#aliased-actions)
- [Available options](#available-options)
- [Available environment variables](#available-environment-variables)
- [Actions in details](#actions-in-details)
- [`deploy`](#deploy)
- [`rm`](#rm)
- [`ls`](#ls)
- [`status`](#status)
- [`services`](#services)
- [`tasks`](#tasks)
- [`tasks:healthy`](#taskshealthy)
- [`containers`](#containers)
- [`login`](#login)
- [`lint`](#lint)
- [`inspect`](#inspect)
- [`system:info`](#systeminfo)
- [`actions`](#actions)
- [`help`](#help)
- [`version`](#version)
- [Options in details](#options-in-details)
- [Stack environment variables](#stack-environment-variables)
- [Verbose mode](#verbose-mode)
- [Debug mode](#debug-mode)
- [Strict mode](#strict-mode)
- [Quiet mode](#quiet-mode)
- [`detect-job` option](#detect-job-option)
- [Glossary](#glossary)
- [Job](#job)
<!-- /MDTOC -->
</div>
## Available actions
| Name | Description |
| --------------------------------- | ----------- |
| [`deploy`](#deploy) | Deploy/update the given stack. |
| [`rm`](#rm) | Remove/undeploy the given stack. |
| [`ls`](#ls) | List stacks already deployed. |
| [`status`](#status) | Check if the stack is running/deployed correctly. |
| [`services`](#services) | List services already deployed in the current stack. |
| [`tasks`](#tasks) | List tasks in the current stack. |
| [`tasks:healthy`](#taskshealthy) | List tasks who are running correctly in the current stack. |
| [`containers`](#containers) | List containers running in the current stack. |
| [`login`](#login) | Log in to a Portainer instance. |
| [`lint`](#lint) | Validate the Docker compose/stack file. |
| [`inspect`](#inspect) | Display low-level information of the current stack. |
| [`system:info`](#systeminfo) | Display Docker system-wide information. |
| [`actions`](#actions) | List available actions for this program. |
| [`help`](#help) | Display help message. |
| [`version`](#version) | Display this program version. |
### Aliased actions
| Aliased action | Equivalent action |
| ------------------ | ---------------------------------- |
| `auth` | [`login`](#login) |
| `docker:info` | [`system:info`](#systeminfo) |
| `list` | [`ls`](#ls) |
| `ps` | [`tasks`](#tasks) |
| `ps:healthy` | [`tasks:healthy`](#taskshealthy) |
| `remove` | [`rm`](#rm) |
| `undeploy` | [`rm`](#rm) |
| `update` | [`deploy`](#deploy) |
| `validate` | [`lint`](#lint) |
## Available options
<!-- [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [lint](#lint), [inspect](#inspect), [system:info](#systeminfo), [actions](#actions), [help](#help), [version](#version) | -->
| Flag | Option | Description | Used in action(s) |
| -----------| -------------------------------- | ----------- | ----------------- |
| `-l` | `--url=URL` | URL of the Portainer instance | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `-u` | `--user=USERNAME` | Username of the Portainer instance | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `-n` | `--name=STACK_NAME` | Stack name | [deploy](#deploy), [rm](#rm), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [inspect](#inspect) |
| `-c`, `-f` | `--compose-file=FILE_PATH` | Path to docker compose/stack file (required if action=deploy) | [deploy](#deploy), [lint](#lint) |
| `-C`, `-F` | `--compose-file-base64=[BASE64]` | Content of docker compose/stack file, encoded in base64, useful with Docker in Docker (only used when action=deploy) | [deploy](#deploy), [lint](#lint) |
| `-g` | `--env-file=[FILE_PATH]` | Path to a file of environment variables, to be used by the stack (only used when action=deploy) | [deploy](#deploy) |
| `-G` | `--env-file-base64=[BASE64]` | Content of file with environment variables, encoded in base64, to be used by the stack, useful with Docker in Docker (only used when action=deploy) | [deploy](#deploy) |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `-r` | `--prune` | Whether to prune unused containers or not (only used when action=deploy). Defaults to `false` | [deploy](#deploy) |
| `-T` | `--timeout=[SECONDS]` | Timeout, number of seconds before thrown an error (only used when action=status\|tasks\|tasks:healthy). Defaults to `100` | [status](#status), [tasks](#tasks), [tasks:healthy](#taskshealthy) |
| `-j` | `--detect-job=[true\|false]` | Auto detect services who are jobs in the current stack. Defaults to `true` | [status](#status), [tasks](#tasks), [tasks:healthy](#taskshealthy) |
| `-S` | `--service=[SERVICE_NAME]` | Filtering by a service name of the current stack (only used when action=status\|tasks\|tasks:healthy\|containers) | [status](#status), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers) |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [lint](#lint), [inspect](#inspect), [system:info](#systeminfo), [actions](#actions) |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [lint](#lint), [inspect](#inspect), [system:info](#systeminfo), [actions](#actions) |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `-q` | `--quiet` | Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to `false` | [ls](#ls), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [inspect](#inspect) |
| `-t` | `--strict` | Never updates an existent stack nor removes an inexistent one, and instead exits with an error. Defaults to `false` | [deploy](#deploy), [rm](#rm) |
| `-L` | `--lint=[true\|false]` | Validate the Docker compose/stack file before deploying the stack (only used when action=deploy). Defaults to `true` | [deploy](#deploy) |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [lint](#lint), [inspect](#inspect), [system:info](#systeminfo), [actions](#actions), [version](#version) |
| `-V` | `--version` | Display the version of this program | |
| `-s` | `--secure=[yes\|no]` | **DEPRECATED**: Use the `--insecure` option instead. Enable or disable the host's SSL certificate verification. Defaults to `yes` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `-a` | `--action=[ACTION_NAME]` | **DEPRECATED**: Use `<action>` argument instead. The name of the action to execute | |
## Available environment variables
| Environment variable | Description | Used in action(s) |
| ------------------------------------------- | -------------- | ----------------- |
| `ACTION=ACTION_NAME` | The name of the action to execute | <abbr title="not applicable">n/a</abbr> |
| `PORTAINER_URL=URL` | URL of the Portainer instance | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `PORTAINER_USER=USERNAME` | Username of the Portainer instance | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `PORTAINER_PASSWORD=PASSWORD` | Password of the Portainer instance | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `PORTAINER_AUTH_TOKEN=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `PORTAINER_STACK_NAME=STACK_NAME` | Stack name | [deploy](#deploy), [rm](#rm), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [inspect](#inspect) |
| `DOCKER_COMPOSE_FILE=FILE_PATH` | Path to docker compose/stack file (required if action=deploy) | [deploy](#deploy), [lint](#lint) |
| `ENVIRONMENT_VARIABLES_FILE=[FILE_PATH]` | Path to a file of environment variables, to be used by the stack (only used when action=deploy) | [deploy](#deploy) |
| `PORTAINER_ENDPOINT=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `PORTAINER_PRUNE=[true\|false]` | Whether to prune unused containers or not (only used when action=deploy). Defaults to `false` | [deploy](#deploy) |
| `TIMEOUT=[SECONDS]` | Timeout, number of seconds before thrown an error (only used when action=status\|tasks\|tasks:healthy). Defaults to `100` | [status](#status), [tasks](#tasks), [tasks:healthy](#taskshealthy) |
| `AUTO_DETECT_JOB=[true\|false]` | Auto detect services who are jobs in the current stack. Defaults to `true` | [status](#status), [tasks](#tasks), [tasks:healthy](#taskshealthy) |
| `PORTAINER_SERVICE_NAME=[SERVICE_NAME]` | Filtering by a service name of the current stack (only used when action=status\|tasks\|tasks:healthy\|containers) | [status](#status), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers) |
| `HTTPIE_VERIFY_SSL=[yes\|no\|CA_BUNDLE_PATH]` | Enable or disable the host's SSL certificate verification. Defaults to `yes`. You can also set a custom <abbr title="Certificate Authority">CA</abbr> bundle path | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `VERBOSE_MODE=[true\|false]` | Increase the verbosity of messages. Defaults to `false` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [lint](#lint), [inspect](#inspect), [system:info](#systeminfo), [actions](#actions) |
| `DEBUG_MODE=[true\|false]` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [lint](#lint), [inspect](#inspect), [system:info](#systeminfo), [actions](#actions) |
| `MASKED_VARIABLES=[true\|extended\|false]` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) |
| `QUIET_MODE=[true\|false]` | Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to `false` | [ls](#ls), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [inspect](#inspect) |
| `STRICT_MODE=[true\|false]` | Never updates an existent stack nor removes an inexistent one, and instead exits with an error. Defaults to `false` | [deploy](#deploy), [rm](#rm) |
| `DOCKER_COMPOSE_LINT=[true\|false]` | Validate the Docker compose/stack file before deploying the stack (only used when action=deploy). Defaults to `true` | [deploy](#deploy) |
<!-- | `PORTAINER_INSECURE=[true\|false]` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` | [deploy](#deploy), [rm](#rm), [ls](#ls), [status](#status), [services](#services), [tasks](#tasks), [tasks:healthy](#taskshealthy), [containers](#containers), [login](#login), [inspect](#inspect), [system:info](#systeminfo) | -->
<!-- | `DOCKER_COMPOSE_BASE64=[BASE64]` | Content of docker compose/stack file, encoded in base64, useful with Docker in Docker (only used when action=deploy) | [deploy](#deploy), [lint](#lint) | -->
<!-- | `ENVIRONMENT_VARIABLES_BASE64=[BASE64]` | Content of file with environment variables, encoded in base64, to be used by the stack, useful with Docker in Docker (only used when action=deploy) | [deploy](#deploy) | -->
## Actions in details
### `deploy`
Deploy/update the given stack.
#### Aliased action:
`update`
#### Usage:
`psu deploy [options]`
#### Examples:
```bash
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
```
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
| `-n` | `--name=STACK_NAME` | Stack name |
| `-c`, `-f` | `--compose-file=FILE_PATH` | Path to docker compose/stack file (required if action=deploy) |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-L` | `--lint=[true\|false]` | Validate the Docker compose/stack file before deploying the stack (only used when action=deploy). Defaults to `true` |
| `-C`, `-F` | `--compose-file-base64=[BASE64]` | Content of docker compose/stack file, encoded in base64, useful with Docker in Docker (only used when action=deploy) |
| `-g` | `--env-file=[FILE_PATH]` | Path to a file of environment variables, to be used by the stack (only used when action=deploy) |
| `-G` | `--env-file-base64=[BASE64]` | Content of file with environment variables, encoded in base64, to be used by the stack, useful with Docker in Docker (only used when action=deploy) |
| `-r` | `--prune` | Whether to prune unused containers or not (only used when action=deploy). Defaults to `false` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-t` | `--strict` | Never updates an existent stack nor removes an inexistent one, and instead exits with an error. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `rm`
Remove/undeploy the given stack.
#### Aliased actions:
`remove`, `undeploy`
#### Usage:
`psu rm [options]`
#### Examples:
```bash
psu rm --user admin --password password --url https://portainer.local --name mystack
```
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
| `-n` | `--name=STACK_NAME` | Stack name |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-t` | `--strict` | Never updates an existent stack nor removes an inexistent one, and instead exits with an error. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `ls`
List stacks already deployed.
#### Aliased actions:
`list`
#### Usage:
`psu ls [options]`
#### Examples:
```bash
psu ls --user admin --password password --url https://portainer.local
```
Output a JSON array of the stacks already deployed:
```json
[
{
"Id": "mystack_jpofkc0i9uo9wtx1zesuk649w",
"Name": "mystack",
"Type": "1",
"EndpointID": "1",
"EntryPoint": "docker-compose.yml",
"SwarmID": "jpofkc0i9uo9wtx1zesuk649w",
"ProjectPath": "/data/compose/mystack_jpofkc0i9uo9wtx1zesuk649w",
"Env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "password"
}
]
},
{
"Id": "mysecondstack_i0649w9uo9wtx1zesujpofkck",
"Name": "mysecondstack",
"Type": "1",
"EndpointID": "1",
"EntryPoint": "docker-compose.yml",
"SwarmID": "i0649w9uo9wtx1zesujpofkck",
"ProjectPath": "/data/compose/mysecondstack_i0649w9uo9wtx1zesujpofkck"
},
{
"Id": "mythirdstack_w9uo9wtxi064ujpofkck91zes",
"Name": "mythirdstack",
"Type": "1",
"EndpointID": "1",
"EntryPoint": "docker-compose.yml",
"SwarmID": "mythirdstack_w9uo9wtxi064ujpofkck91zes",
"ProjectPath": "/data/compose/mythirdstack_mythirdstack_w9uo9wtxi064ujpofkck91zes"
},
]
```
**With the `quiet` mode enabled**:
```bash
psu ls --user admin --password password --url https://portainer.local --quiet
```
Output the name of the stacks already deployed:
```bash
mystack
mysecondstack
mythirdstack
```
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-q` | `--quiet` | Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to `false` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `status`
Check if the stack is running/deployed correctly
If your stack has some services who acts as [jobs](#job), see the [`--detect-job`](#detect-job-option) option for more details.
This action is very useful in CI/CD pipelines, it's equivalent to the [`kubectl rollout status`](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-status-em-) command of Kubernetes.
#### Usage:
`psu status [options]`
#### Examples:
```bash
psu status --user admin --password password --url https://portainer.local --name mystack
```
This command outputs nothing if the stack is correctly running or deployed.
It also has an exit code (or exit status).
The exit code value return based on a command or program will successfully execute _(return 0)_ or not _(return 1 or higher)_.
```bash
psu status --user admin --password password --url https://portainer.local --name mystack --timeout 20
if [ $? -eq 0 ]; then
echo "[OK] This stack is running/deployed correctly"
else
echo "[ERROR] This stack isn't running/deployed correctly!"
fi
```
For more informations about exit code, you can read this [article](https://tecadmin.net/tutorial/bash-scripting/bash-exit-codes/) and this [Wikipedia page](https://en.wikipedia.org/wiki/Exit_status)
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
| `-n` | `--name=STACK_NAME` | Stack name |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-S` | `--service=[SERVICE_NAME]` | Filtering by a service name of the current stack (only used when action=status\|tasks\|tasks:healthy\|containers) |
| `-j` | `--detect-job=[true\|false]` | Auto detect services who are jobs in the current stack. Defaults to `true` |
| `-T` | `--timeout=[SECONDS]` | Timeout, number of seconds before thrown an error (only used when action=status\|tasks\|tasks:healthy). Defaults to `100` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `services`
List services already deployed in the current stack.
#### Usage:
`psu services [options]`
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
| `-n` | `--name=STACK_NAME` | Stack name |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-q` | `--quiet` | Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to `false` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `tasks`
List tasks in the current stack.
If your stack has some services who acts as [jobs](#job), see the [`--detect-job`](#detect-job-option) option for more details.
#### Usage:
`psu tasks [options]`
#### Aliased action:
`ps`
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
| `-n` | `--name=STACK_NAME` | Stack name |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-S` | `--service=[SERVICE_NAME]` | Filtering by a service name of the current stack (only used when action=status\|tasks\|tasks:healthy\|containers) |
| `-j` | `--detect-job=[true\|false]` | Auto detect services who are jobs in the current stack. Defaults to `true` |
| `-T` | `--timeout=[SECONDS]` | Timeout, number of seconds before thrown an error (only used when action=status\|tasks\|tasks:healthy). Defaults to `100` |
| `-q` | `--quiet` | Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to `false` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `tasks:healthy`
List tasks who are running correctly in the current stack.
If your stack has some services who acts as [jobs](#job), see the [`--detect-job`](#detect-job-option) option for more details.
#### Usage:
`psu tasks:healthy [options]`
#### Aliased action:
`ps:healthy`
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
| `-n` | `--name=STACK_NAME` | Stack name |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-S` | `--service=[SERVICE_NAME]` | Filtering by a service name of the current stack (only used when action=status\|tasks\|tasks:healthy\|containers) |
| `-j` | `--detect-job=[true\|false]` | Auto detect services who are jobs in the current stack. Defaults to `true` |
| `-T` | `--timeout=[SECONDS]` | Timeout, number of seconds before thrown an error (only used when action=status\|tasks\|tasks:healthy). Defaults to `100` |
| `-q` | `--quiet` | Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to `false` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `containers`
List containers running in the current stack.
#### Usage:
`psu containers [options]`
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
| `-n` | `--name=STACK_NAME` | Stack name |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-S` | `--service=[SERVICE_NAME]` | Filtering by a service name of the current stack (only used when action=status\|tasks\|tasks:healthy\|containers) |
| `-q` | `--quiet` | Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to `false` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `login`
Log in to a Portainer instance.
#### Usage:
`psu login [options]`
#### Aliased action:
`auth`
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `lint`
Validate the Docker compose/stack file.
#### Usage:
`psu lint [options]`
#### Aliased action:
`validate`
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-c`, `-f` | `--compose-file=FILE_PATH` | Path to docker compose/stack file (required if action=deploy) |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-C`, `-F` | `--compose-file-base64=[BASE64]` | Content of docker compose/stack file, encoded in base64, useful with Docker in Docker (only used when action=deploy) |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `inspect`
Display low-level information of the current stack.
#### Usage:
`psu inspect [options]`
#### Examples:
```bash
psu inspect --user admin --password password --url https://portainer.local --name mystack
```
Output the JSON object of the stack if it's already deployed:
```json
{
"Id": "mystack_jpofkc0i9uo9wtx1zesuk649w",
"Name": "mystack",
"Type": "1",
"EndpointID": "1",
"EntryPoint": "docker-compose.yml",
"SwarmID": "jpofkc0i9uo9wtx1zesuk649w",
"ProjectPath": "/data/compose/mystack_jpofkc0i9uo9wtx1zesuk649w",
"Env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "password"
}
]
}
```
**With the `quiet` mode enabled**:
```bash
psu inspect --user admin --password password --url https://portainer.local --name mystack --quiet
```
Output the stack name if it's already deployed:
```bash
mystack
```
**Check if the stack is already deployed**:
```bash
stack_exist=$(psu inspect --user admin --password password --url https://portainer.local --name mystack)
if [ -n "$stack_exist" ]; then
echo OK
else
echo KO
fi
## OR check the exit code of the last executed command:
stack_exist=$(psu inspect --user admin --password password --url https://portainer.local --name mystack)
status=$?
if $(exit $status); then
echo OK
else
echo KO
fi
```
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
| `-n` | `--name=STACK_NAME` | Stack name |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-q` | `--quiet` | Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to `false` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `system:info`
Display Docker system-wide information.
#### Usage:
`psu system:info [options]`
#### Aliased action:
`docker:info`
#### Required options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-l` | `--url=URL` | URL of the Portainer instance |
| `-u` | `--user=USERNAME` | Username of the Portainer instance |
| `-p` | `--password=PASSWORD` | Password of the Portainer instance |
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-A` | `--auth-token=[AUTH_TOKEN]` | Use a Portainer auth token instead of `--user` and `--password` options, you can get it with the `psu login` command. Defaults to `null` |
| `-e` | `--endpoint=[ENDPOINT_ID]` | Which Docker endpoint to use. Defaults to `1` |
| `-i` | `--insecure` | Skip the host's SSL certificate verification, use at your own risk. Defaults to `false` |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-m` | `--masked-variables` | In debug/verbose mode, value of sensitive variables will be hidden, avoid leaking passwords/tokens in logs. Possible values: true\|extended\|false. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `actions`
List available actions for this program.
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-v` | `--verbose` | Increase the verbosity of messages. Defaults to `false` |
| `-d` | `--debug` | Print as much information as possible to help diagnosing a malfunction. Defaults to `false` |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
### `help`
Display help message.
### `version`
Display this program version.
#### Optional options:
| Flag | Option | Description |
| ---------- | -------------------------------- | ----------- |
| `-h` | `--help` | Display help message. To display help of a given action, run: `psu <action> --help` |
## Options in details
### Stack environment variables
There can be set environment variables for each stack, be it a new deployment or an update. For example:
```bash
touch .env
echo "MYSQL_ROOT_PASSWORD=agoodpassword" >> .env
echo "ALLOWED_HOSTS=*" >> .env
psu deploy --user admin --password password --url https://portainer.local --name mystack --compose-file docker-compose.yml --env-file .env
```
Stack environment variables can be enabled through `ENVIRONMENT_VARIABLES_FILE` envvar or `--env-file` option or `-g` flag.
### Verbose mode
In verbose mode the script prints execution steps.
```text
Getting auth token...
Getting stack mystack...
Stack mystack not found.
Getting Docker info...
Getting swarm cluster (if any)...
Swarm cluster found.
Preparing stack JSON...
Creating stack mystack...
```
Verbose mode can be enabled through `VERBOSE_MODE` envvar or `--verbose` option or `-v` flag.
### Debug mode
In debug mode the script prints as much information as possible to help diagnosing a malfunction.
**WARNING**: Debug mode will print configuration values (with Portainer credentials) and Portainer API responses (with sensitive information like authentication token and stacks environment variables). Avoid using debug mode in CI/CD pipelines, as pipeline logs are usually recorded.
Debug mode can be enabled through `DEBUG_MODE` envvar or `--debug` option or `-d` flag.
### Strict mode
In strict mode the script never updates an existent stack nor removes an inexistent one, and instead exits with an error.
Strict mode can be enabled through `STRICT_MODE` envvar or `--strict` option or `-t` flag.
### Quiet mode
In quiet mode the script prints the minimum of informations or nothing.
It's inspired by the `--quiet` option of [`docker images`](https://docs.docker.com/engine/reference/commandline/images/#options) command.
Quiet mode can be enabled through `QUIET_MODE` envvar or `--quiet` option or `-q` flag.
### `detect-job` option
The `--detect-job` option (`true` by default) detects if a service has a restart policy set to `none` and considered this service as a [Job](#job).
If set to `false`, to considering a service as a [Job](#job), you need to set a container's [label](https://docs.docker.com/compose/compose-file/#labels-1) named `job-name` with the value you want (e.g. `my-job-service-name`) in the Docker compose/stack file.
_See the [Job definition](#job) section for more details._
## Glossary
### Job
Docker (or Portainer) doesn't have a true [Job](https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/) mechanism like [Kubernetes](https://kubernetes.io).
But `psu` use an equivalent Docker behavior, based on filtering tasks status with a specific container's [label](https://docs.docker.com/compose/compose-file/#labels-1) (`job-name`).
Or when, in your Docker compose/stack file, a service [`deploy.restart_policy.condition`](https://docs.docker.com/compose/compose-file/#restart_policy) option is set to `none`.
The `psu` definition of a job is a Swarm [service](https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/) who ensures that all its specified [task(s)](https://docs.docker.com/engine/swarm/how-swarm-mode-works/swarm-task-states/) successfully terminate.
Using a job is useful when you want to have a service who run a script (e.g. database migration).
And shutdown this service when its script is successfully executed.
See the service named `job` in the [`docker-stack-web-app.yml`](https://gitlab.com/psuapp/psu/tree/v1.3.0/tests/dockerfiles/docker-stack-web-app.yml) file, for a real use case.
It has both a container's label `job-name` and a restart policy set to `none`.

View File

@ -0,0 +1,6 @@
# Portainer Stack Utils Documentation
> Bash script to deploy/update/remove stacks in a [Portainer](https://portainer.io/) instance.
[GitLab](https://gitlab.com/psuapp/psu/ ":target=_blank View source on GitLab")
<a href="#../README" title="Read documentation">Getting Started</a>

View File

@ -0,0 +1,4 @@
- [**Getting Started**](../README)
- [**<abbr title="command-line interface">CLI</abbr> Commands**](docs/README)
- [**Changelog**](CHANGELOG)
- [**License**](LICENSE)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
!function(e){var a={variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\([^)]+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},/\$(?:[\w#?*!@]+|\{[^}]+\})/i]};e.languages.bash={shebang:{pattern:/^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/,alias:"important"},comment:{pattern:/(^|[^"{\\])#.*/,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<\s*)["']?(\w+?)["']?\s*\r?\n(?:[\s\S])*?\r?\n\2/,lookbehind:!0,greedy:!0,inside:a},{pattern:/(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,greedy:!0,inside:a}],variable:a.variable,function:{pattern:/(^|[\s;|&])(?:add|alias|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|hash|head|help|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logout|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tail|tar|tee|test|time|timeout|times|top|touch|tr|traceroute|trap|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zip|zypper)(?=$|[\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&])(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|[\s;|&])/,lookbehind:!0},boolean:{pattern:/(^|[\s;|&])(?:true|false)(?=$|[\s;|&])/,lookbehind:!0},operator:/&&?|\|\|?|==?|!=?|<<<?|>>|<=?|>=?|=~/,punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];]/};var t=a.variable[1].inside;t.string=e.languages.bash.string,t.function=e.languages.bash.function,t.keyword=e.languages.bash.keyword,t.boolean=e.languages.bash.boolean,t.operator=e.languages.bash.operator,t.punctuation=e.languages.bash.punctuation,e.languages.shell=e.languages.bash}(Prism);

View File

@ -0,0 +1 @@
Prism.languages.json={comment:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,property:{pattern:/"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,greedy:!0},string:{pattern:/"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,greedy:!0},number:/-?\d+\.?\d*(e[+-]?\d+)?/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:true|false)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}};

View File

@ -0,0 +1,91 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Portainer Stack Utils Documentation</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<!-- <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css"> -->
<link rel="stylesheet" href="assets/docsify_themes_vue.css">
<style>
.docsify-hidden {
display: none;
}
/* source: https://gitlab-corners.bryce.io/ */
.gitlab-corner-wrapper{overflow:hidden;width:100px;height:100px;position:fixed;top:0;right:0}.gitlab-corner{position:absolute;top:-16px;right:-50px;transform:rotate(45deg);background:#548;border:44px solid #548;border-bottom:none;border-top:#548 solid 16px}.gitlab-corner svg{width:60px;height:60px;margin-bottom:-4px}.cls-1{fill:#fc6d26}.cls-2{fill:#e24329}.cls-3{fill:#fca326}.gitlab-corner:hover .cls-1{animation:cycle .6s}.gitlab-corner:hover .cls-2{animation:cycleMid .6s}.gitlab-corner:hover .cls-3{animation:cycleEnd .6s}@keyframes cycle{100%,15%,60%{fill:#fc6d26}30%,75%{fill:#e24329}45%,90%{fill:#fca326}}@keyframes cycleMid{100%,15%,60%{fill:#e24329}30%,75%{fill:#fca326}45%,90%{fill:#fc6d26}}@keyframes cycleEnd{100%,15%,60%{fill:#fca326}30%,75%{fill:#fc6d26}45%,90%{fill:#e24329}}@media (max-width:500px){.gitlab-corner:hover .cls-1,.gitlab-corner:hover .cls-2,.gitlab-corner:hover .cls-3{animation:none}.gitlab-corner .cls-1{animation:cycle .6s}.gitlab-corner .cls-2{animation:cycleMid .6s}.gitlab-corner .cls-3{animation:cycleEnd .6s}}
/* source: https://www.w3schools.com/howto/howto_js_scroll_to_top.asp */
#top-btn{display:none;position:fixed;bottom:15px;right:20px;z-index:99;border:none;outline:none;background-color:#548;color:#fff;cursor:pointer;padding:10px;border-radius:5px;font-size:18px}#top-btn:hover{background-color:#555}
</style>
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: '<abbr title="Portainer Stack Utils">PSU</abbr> Docs ',
// repo: 'https://gitlab.com/psuapp/psu',
coverpage: true,
onlyCover: true,
auto2top: true,
search: 'auto',
maxLevel: 3,
loadSidebar: true,
subMaxLevel: 3,
alias: {
'/CHANGELOG': 'repo/CHANGELOG',
'/LICENSE': 'repo/LICENSE',
'/../README': 'repo/README',
'/docs/README': 'README',
'/.*/_sidebar.md': '/_sidebar.md'
},
search : {
paths: [
'/docs/README', // => /README.md
'/../README', // => /repo/README.md
'/CHANGELOG', // => /repo/CHANGELOG.md
],
depth: 3
},
}
</script>
<!-- <script src="//unpkg.com/docsify/lib/docsify.min.js"></script> -->
<!-- <script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script> -->
<!-- <script src="//unpkg.com/prismjs/components/prism-json.min.js"></script> -->
<!-- <script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script> -->
<script src="assets/docsify.min.js"></script>
<script src="assets/prism-bash.min.js"></script>
<script src="assets/prism-json.min.js"></script>
<script src="assets/docsify_plugins_search.min.js"></script>
<!-- source: https://www.w3schools.com/howto/howto_js_scroll_to_top.asp -->
<script>
(function () {
// When the user scrolls down 100px from the top of the document, show the button
var scrollFunction = function() {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
document.getElementById("top-btn").style.display = "block";
} else {
document.getElementById("top-btn").style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
window.topFunction = function () {
window.scrollTo(0, 0);
}
window.addEventListener("scroll", function () {
scrollFunction();
}, false);
})();
</script>
<button onclick="topFunction()" id="top-btn" title="Go top"></button>
<!-- source: https://gitlab-corners.bryce.io/ -->
<div class="gitlab-corner-wrapper">
<a href="https://gitlab.com/psuapp/psu" class="gitlab-corner" aria-label="View source on GitLab" title="View source on GitLab" target="_blank" rel="noopener">
<svg id="logo_art" data-name="logo art" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 586 559">
<g id="g44"><path id="path46" class="cls-1" d="M461.17,301.83l-18.91-58.12L404.84,128.43a6.47,6.47,0,0,0-12.27,0L355.15,243.64H230.82L193.4,128.43a6.46,6.46,0,0,0-12.26,0L143.78,243.64l-18.91,58.19a12.88,12.88,0,0,0,4.66,14.39L293,435,456.44,316.22a12.9,12.9,0,0,0,4.73-14.39"/></g><g id="g48"><path id="path50" class="cls-2" d="M293,434.91h0l62.16-191.28H230.87L293,434.91Z"/></g><g id="g56"><path id="path58" class="cls-1" d="M293,434.91,230.82,243.63h-87L293,434.91Z"/></g><g id="g64"><path id="path66" class="cls-3" d="M143.75,243.69h0l-18.91,58.12a12.88,12.88,0,0,0,4.66,14.39L293,435,143.75,243.69Z"/></g><g id="g72"><path id="path74" class="cls-2" d="M143.78,243.69h87.11L193.4,128.49a6.47,6.47,0,0,0-12.27,0l-37.35,115.2Z"/></g><g id="g76"><path id="path78" class="cls-1" d="M293,434.91l62.16-191.28H442.3L293,434.91Z"/></g><g id="g80"><path id="path82" class="cls-3" d="M442.24,243.69h0l18.91,58.12a12.85,12.85,0,0,1-4.66,14.39L293,434.91l149.2-191.22Z"/></g><g id="g84"><path id="path86" class="cls-2" d="M442.28,243.69h-87.1l37.42-115.2a6.46,6.46,0,0,1,12.26,0l37.42,115.2Z"/></g>
</svg>
</a>
</div>
</body>
</html>

View File

@ -0,0 +1,212 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [1.3.0] - 2021-12-07
### Added
- Add `linux/arm/v7` architecture to support Raspberry Pi
### Changed
- Use Docker [Compose 2.2.2](https://github.com/docker/compose/releases/tag/v2.2.2) instead of Docker [Compose 2.1.1](https://github.com/docker/compose/releases/tag/v2.1.1)
### Fixed
- `psu` was unusable when using a custom <abbr title="Certificate Authority">CA</abbr>, with the `HTTPIE_VERIFY_SSL` env
## [1.3.0-beta.1] - 2021-11-30
### Added
- Docker images are now multi-architecture (`linux/amd64` and `linux/arm64` 🦾)
- [macOS](https://apple.com/macos) support
- [Windows](https://microsoft.com/windows) support, but it could be unstable ⚠️
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.9.3](https://app.swaggerhub.com/apis/portainer/portainer-ce/2.9.3) API
### Changed
- Upgrade Operating System of Docker based images, with [Alpine 3.15](https://hub.docker.com/_/alpine)
- Use Docker [Compose 2.1.1](https://github.com/docker/compose/releases/tag/v2.1.1) instead of Docker [Compose 1.x](https://github.com/docker/compose/releases/tag/1.28.0)
- Reduce Docker images size, based on Alpine and Debian, again
- Replace `master` by `main` git branch name in scripts. Reference: [New git default branch name](https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/)
### Fixed
- Fix documentation scrolling between pages, with the [`auto2top`](https://docsify.js.org/#/configuration?id=auto2top) option of [docsify](https://docsify.js.org)
### Removed
- Remove parallel requests improvement, because it's buggy in some situations...
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [2.1.1](https://app.swaggerhub.com/apis/deviantony/Portainer/2.0.1) API
## [1.3.0-alpha] - 2021-09-14
### Changed
- **Breaking Change**: [HTTPie](https://httpie.io/) is replaced by [cURL](https://curl.se), for smaller Docker images, faster execution and to be more portable
- Boost performance for some actions like `status`, `tasks` and `tasks:healthy`, with parallel requests
### Fixed
- Running concurrently `psu` commands should work now, by creating unique temporary file names
- Fix `psu tasks:healthy` action output, when an error occurs
## [1.2.0] - 2021-09-14
### Added
- Add tests for `actions`, `containers` and `services` actions
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.24.2](https://app.swaggerhub.com/apis/deviantony/Portainer/1.24.1) API
### Changed
- Downgrade Docker Compose from [1.29.2](https://github.com/docker/compose/releases/tag/1.29.2) to [1.28.0](https://github.com/docker/compose/releases/tag/1.28.0) for Alpine image, to get faster builds 🚀
- Reduce Docker images size based on Alpine, again
- Better documentation
### Fixed
- Tests should run fine now with macOS
### Removed
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.24.1](https://app.swaggerhub.com/apis/deviantony/Portainer/1.24.1) API
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [2.0.1](https://app.swaggerhub.com/apis/deviantony/Portainer/2.0.1) API
## [1.2.0-beta.1] - 2021-09-03
### Added
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.5.1](https://app.swaggerhub.com/apis/portainer/portainer-ce/2.5.1) API
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.6.3](https://app.swaggerhub.com/apis/portainer/portainer-ce/2.6.3) API
### Changed
- Use Docker [Compose 1.29.2](https://github.com/docker/compose/releases/tag/1.29.2) instead of Docker [Compose 1.28.3](https://github.com/docker/compose/releases/tag/1.28.3)
- Upgrade Operating System of Docker based images, with [Alpine 3.14](https://hub.docker.com/_/alpine) and [Debian 11](https://hub.docker.com/_/debian)
- Reduce Docker images size
- Use [Traefik 2.5](https://doc.traefik.io/traefik/v2.5) instead of [Traefik 2.4](https://doc.traefik.io/traefik/v2.4) for testing
### Fixed
- Fix [`rm`](docs/README.md#rm) <small>(remove)</small> action with Portainer <abbr title="Community Edition">CE</abbr> 2.6
## [1.2.0-alpha] - 2021-02-19
### Added
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.0.1](https://app.swaggerhub.com/apis/deviantony/Portainer/2.0.1) API
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.1.1](https://app.swaggerhub.com/apis/deviantony/Portainer/2.0.1) API
### Changed
- Use Docker [Compose 1.28.3](https://github.com/docker/compose/releases/tag/1.28.3) instead of Docker [Compose 1.26.2](https://github.com/docker/compose/releases/tag/1.26.2)
- Use [Traefik 2.4](https://doc.traefik.io/traefik/v2.4) instead of [Traefik 2.2](https://doc.traefik.io/traefik/v2.2) for testing
- Upgrade Operating System of Docker based images, with [Alpine 3.13](https://hub.docker.com/_/alpine)
### Removed
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.22.2](https://app.swaggerhub.com/apis/deviantony/Portainer/1.22.2) API
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.23.2](https://app.swaggerhub.com/apis/deviantony/Portainer/1.23.2) API
## [1.1.0] - 2021-02-18
### Changed
- Use [Traefik 2.2](https://doc.traefik.io/traefik/v2.2) instead of [Traefik 2.1](https://doc.traefik.io/traefik/v2.1) for testing
### Fixed
- Changelog link for `psu` version `1.1.0-alpha`
- Fix `cryptography` building error
## [1.1.0-alpha] - 2020-07-29
### Changed
- Upgrade Operating System of Docker based images, with [Alpine 3.12](https://hub.docker.com/_/alpine) and [Debian 10](https://hub.docker.com/_/debian)
### Fixed
- Docker build should fail if a shell command failed
## [1.0.7] - 2021-02-16
### Fixed
- Remove useless packages after building `docker-compose`, for the main Docker image
## [1.0.6] - 2021-02-16
### Fixed
- Docker build should fail if a shell command failed
- Fix `cryptography` building error
## [1.0.5] - 2020-07-29
### Added
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.24.1](https://app.swaggerhub.com/apis/deviantony/Portainer/1.24.1) API
### Removed
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.21.0](https://app.swaggerhub.com/apis/deviantony/Portainer/1.21.0) API
## [1.0.4] - 2020-01-27
### Added
- Use the `$CLEANUP_REGISTRIES_ENABLED` CI variable for deleting Docker repository tags in bulk
### Changed
- Remove unused git and Docker tags in `README.md`
### Fixed
- Fix scheduled pipeline who update Docker images for the latest stable git tag
## [1.0.3] - 2020-01-09
### Added
- Cleaning old Docker repository builds tags via [GitLab API](https://docs.gitlab.com/12.6/ee/api/container_registry.html#delete-repository-tags-in-bulk)
### Changed
- Use [Traefik 2.1](https://doc.traefik.io/traefik/v2.1) instead of [Traefik 1.7](https://doc.traefik.io/traefik/v1.7) for testing
### Fixed
- Build script for the latest stable git tag of a given git branch
## [1.0.2] - 2019-12-10
### Added
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer [1.23.0](https://app.swaggerhub.com/apis/deviantony/Portainer/1.23.0) API
## [1.0.1] - 2019-10-29
### Fixed
- If the `--insecure` option is set to `false` and the `HTTPIE_VERIFY_SSL` environment variable is set, we keep its value instead of overwrite it to `yes`.
Useful when we want to use Custom <abbr title="Certificate Authority">CA</abbr> (e.g. `HTTPIE_VERIFY_SSL=/etc/ssl/certs/ca-certificates.crt`). For more information, you can read the [HTTPie docs](https://httpie.org/doc/1.0.3#custom-ca-bundle)
## [1.0.0] - 2019-07-25
### Added
- New actions: `ls`, `status`, `services`, `tasks`, `tasks:healthy`, `containers`, `login`, `lint`, `inspect`, `system:info`, `actions`, `help` and `version`
- New options: `--auth-token=[AUTH_TOKEN]`, `--compose-file-base64=[BASE64]`, `--env-file-base64=[BASE64]`, `--timeout=[SECONDS]`, `--detect-job=[true|false]`, `--service=[SERVICE_NAME]`, `--insecure`, `--masked-variables`, `--quiet`, `--lint`, `--help` and `--version`
- New flags: `-A`, `-C`, `-F`, `-G`, `-T`, `-j`, `-i`, `-S`, `-m`, `-q`, `-L`, `-h` and `-V`
- New environment variables: `PORTAINER_AUTH_TOKEN`, `TIMEOUT`, `AUTO_DETECT_JOB`, `PORTAINER_SERVICE_NAME`, `MASKED_VARIABLES`, `QUIET_MODE` and `DOCKER_COMPOSE_LINT`
- The Docker image include now `docker-compose` to be able to lint Docker compose/stack file
- The `core` Docker image 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
- The `debian` and `debian-core` Docker image variants, use [Debian](https://www.debian.org) instead of [Alpine](https://alpinelinux.org/) as base image for `psu`
- Online documentation via [docsify](https://docsify.js.org)
- Tests who run automatically on each git push via [GitLab CI](https://docs.gitlab.com/ce/ci/)
### Changed
- The `undeploy` action is now an aliased action. You should use `rm` action instead
### Deprecated
- The `--secure=[yes|no]` option and `-s` flag are deprecated. Use the `--insecure` option instead (`psu <action> ... --insecure`)
- The `--action=[ACTION_NAME]` option and `-a` flag are deprecated. Use `<action>` argument instead (`psu <action> ...`)
## [0.1.2] - 2019-10-29
### Changed
- Delegated compose file loading and escaping to jq [#33](https://gitlab.com/psuapp/psu/merge_requests/33)
## [0.1.1] - 2019-06-05
### Fixed
- Fixed error when environment variables loaded from file contain spaces in their values [#14](https://gitlab.com/psuapp/psu/merge_requests/14)
## [0.1.0] - 2019-05-24
### Added
- Stack deployment
- Stack update
- Stack undeployment
- Configuration through environment variables
- Configuration through flags
- Stack environment variables loading from file
- Optional SSL verification of Portainer instance
- Verbose mode
- Debug mode
- Strict mode
[Unreleased]: https://gitlab.com/psuapp/psu/compare/v1.3.0...1-3-stable
[1.3.0]: https://gitlab.com/psuapp/psu/-/tags/v1.3.0
[1.3.0-beta.1]: https://gitlab.com/psuapp/psu/-/tags/v1.3.0-beta.1
[1.3.0-alpha]: https://gitlab.com/psuapp/psu/-/tags/v1.3.0-alpha
[1.2.0]: https://gitlab.com/psuapp/psu/-/tags/v1.2.0
[1.2.0-beta.1]: https://gitlab.com/psuapp/psu/-/tags/v1.2.0-beta.1
[1.2.0-alpha]: https://gitlab.com/psuapp/psu/-/tags/v1.2.0-alpha
[1.1.0]: https://gitlab.com/psuapp/psu/-/tags/v1.1.0
[1.1.0-alpha]: https://gitlab.com/psuapp/psu/-/tags/v1.1.0-alpha
[1.0.7]: https://gitlab.com/psuapp/psu/-/tags/v1.0.7
[1.0.6]: https://gitlab.com/psuapp/psu/-/tags/v1.0.6
[1.0.5]: https://gitlab.com/psuapp/psu/-/tags/v1.0.5
[1.0.4]: https://gitlab.com/psuapp/psu/-/tags/v1.0.4
[1.0.3]: https://gitlab.com/psuapp/psu/-/tags/v1.0.3
[1.0.2]: https://gitlab.com/psuapp/psu/-/tags/v1.0.2
[1.0.1]: https://gitlab.com/psuapp/psu/-/tags/v1.0.1
[1.0.0]: https://gitlab.com/psuapp/psu/-/tags/v1.0.0
[0.1.2]: https://gitlab.com/psuapp/psu/-/tags/v0.1.2
[0.1.1]: https://gitlab.com/psuapp/psu/-/tags/v0.1.1
[0.1.0]: https://gitlab.com/psuapp/psu/-/tags/v0.1.0

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -0,0 +1,311 @@
<h1>Portainer Stack Utils</h1>
<div class="docsify-hidden">
[![Docker Pulls](https://img.shields.io/docker/pulls/psuapp/psu.svg)](https://hub.docker.com/r/psuapp/psu/)
[![pipeline status](https://gitlab.com/psuapp/psu/badges/1-3-stable/pipeline.svg)](https://gitlab.com/psuapp/psu/commits/1-3-stable)
Bash script to deploy/update/remove stacks in a [Portainer](https://portainer.io/) instance from a [docker-compose](https://docs.docker.com/compose) [yaml file](https://docs.docker.com/compose/compose-file).
_Based on previous work by [@vladbabii](https://github.com/vladbabii) on [docker-how-to/portainer-bash-scripts](https://github.com/docker-how-to/portainer-bash-scripts)._
<h2>Table of contents</h2>
<!-- Generated by https://github.com/mcpride/atom-mdtoc -->
<!-- MDTOC maxdepth:2 firsth1:2 numbering:0 flatten:0 bullets:1 updateOnSave:1 -->
- [How to install](#how-to-install)
- [Standalone](#standalone)
- [Docker image, variants and multi-architecture](#docker-image-variants-and-multi-architecture)
- [How to use](#how-to-use)
- [With options](#with-options)
- [With flags](#with-flags)
- [With envvars](#with-envvars)
- [Documentation](#documentation)
- [Supported Portainer API](#supported-portainer-api)
- [License](#license)
<!-- /MDTOC -->
</div>
## How to install
### Standalone
> **Note**: The easiest way to install `psu` is to use [Docker method](#docker-image-and-variants), instead of this one
Check the [Requirements](#requirements) section then [git] clone the repo and use the [bash] script below:
```bash
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](#how-to-use) section.
#### Requirements
You will need these dependencies installed:
##### [Linux] based systems <small>([Alpine], [Debian], [Ubuntu]...)</small>
- [bash]<sup title="required">\*</sup> <small>(>= 4.4.23)</small>
- [curl]<sup title="required">\*</sup> <small>(>= 7.64.0, but >= 7.76.0 is recommended)</small>
- [jq]<sup title="required">\*</sup> <small>(>= 1.5.1)</small>
- [uuidgen] recommended only for some <abbr title="Operating System">OS</abbr> <small>(Alpine and Debian work fine without it)</small>
For [Debian] and similar apt-powered [Linux] systems, run: `apt install bash curl jq`
##### [macOS]
- [bash]<sup title="required">\*</sup> <small>(>= 4.4.23)</small>
- [curl]<sup title="required">\*</sup> <small>(>= 7.64.0, but >= 7.76.0 is recommended)</small>
- [jq]<sup title="required">\*</sup> <small>(>= 1.5.1)</small>
- [timeout]<sup title="required">\*</sup> <small>(included in the [coreutils] package)</small>
- greadlink <small>(included in the [coreutils] package)</small>
You should install [Homebrew], then run: `brew install bash coreutils jq`
##### [Windows]
- [bash]<sup title="required">\*</sup> <small>(>= 4.4.23)</small>
- [curl]<sup title="required">\*</sup> <small>(>= 7.64.0, but >= 7.76.0 is recommended)</small>
- [jq]<sup title="required">\*</sup> <small>(>= 1.5.1)</small>
> **Note**: `psu`should work with [Windows], but it could be unstable ⚠️
You should download and install [Git](https://git-scm.com/download/win) and [jq](https://stedolan.github.io/jq/download) for [Windows]
##### For all systems
- [docker-compose] is recommended but not required <small>(useful for linting docker compose/stack files)</small>
<sup>\*</sup> = required
### Docker image, variants and multi-architecture
If you don't want or can't install `psu` and its dependencies, you can run it with the default [published Docker image](https://hub.docker.com/r/psuapp/psu), like this:
```bash
docker run psuapp/psu:1.3 deploy ...
```
> **Note**: Docker images are also available on [GitLab](https://gitlab.com/psuapp/psu/container_registry).
For detailed instructions, see [How to use](#how-to-use) section.
#### Supported tags
Published Docker images are [tagged](https://hub.docker.com/r/psuapp/psu/tags) matching [GitLab tags](https://gitlab.com/psuapp/psu/-/tags):
<!-- - `dev` -> [`dev`](https://gitlab.com/psuapp/psu/-/tags/dev) -->
- `1`, `1.3`, `1.3.0` -> [`v1.3.0`](https://gitlab.com/psuapp/psu/-/tags/v1.3.0)
- `1.3.0-beta.1` -> [`v1.3.0-beta.1`](https://gitlab.com/psuapp/psu/-/tags/v1.3.0-beta.1)
- `1.3.0-alpha` -> [`v1.3.0-alpha`](https://gitlab.com/psuapp/psu/-/tags/v1.3.0-alpha)
- `1.2`, `1.2.0` -> [`v1.2.0`](https://gitlab.com/psuapp/psu/-/tags/v1.2.0)
- `1.2.0-beta.1` -> [`v1.2.0-beta.1`](https://gitlab.com/psuapp/psu/-/tags/v1.2.0-beta.1)
- `1.2.0-alpha` -> [`v1.2.0-alpha`](https://gitlab.com/psuapp/psu/-/tags/v1.2.0-alpha)
- `1.1`, `1.1.0` -> [`v1.1.0`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0)
- `1.1.0-alpha` -> [`v1.1.0-alpha`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0-alpha)
- `1.0`, `1.0.7` -> [`v1.0.7`](https://gitlab.com/psuapp/psu/-/tags/v1.0.7)
- `1.0.6` -> [`v1.0.6`](https://gitlab.com/psuapp/psu/-/tags/v1.0.6)
- `1.0.5` -> [`v1.0.5`](https://gitlab.com/psuapp/psu/-/tags/v1.0.5)
- `1.0.4` -> [`v1.0.4`](https://gitlab.com/psuapp/psu/-/tags/v1.0.4)
- `1.0.3` -> [`v1.0.3`](https://gitlab.com/psuapp/psu/-/tags/v1.0.3)
- `1.0.2` -> [`v1.0.2`](https://gitlab.com/psuapp/psu/-/tags/v1.0.2)
- `1.0.1` -> [`v1.0.1`](https://gitlab.com/psuapp/psu/-/tags/v1.0.1)
- `1.0.0` -> [`v1.0.0`](https://gitlab.com/psuapp/psu/-/tags/v1.0.0)
- `0.1.2` -> [`v0.1.2`](https://gitlab.com/psuapp/psu/-/tags/v0.1.2)
- `0.1.1` -> [`v0.1.1`](https://gitlab.com/psuapp/psu/-/tags/v0.1.1)
- `0.1.0` -> [`v0.1.0`](https://gitlab.com/psuapp/psu/-/tags/v0.1.0)
##### 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.
<!-- - `dev-core` -> [`dev`](https://gitlab.com/psuapp/psu/-/tags/dev) -->
- `1-core`, `1.3-core`, `1.3.0-core` -> [`v1.3.0`](https://gitlab.com/psuapp/psu/-/tags/v1.3.0)
- `1.2-core`, `1.2.0-core` -> [`v1.2.0`](https://gitlab.com/psuapp/psu/-/tags/v1.2.0)
- `1.1-core`, `1.1.0-core` -> [`v1.1.0`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0)
- `1.0-core`, `1.0.7-core` -> [`v1.0.7`](https://gitlab.com/psuapp/psu/-/tags/v1.0.7)
The `debian` and `debian-core` variants use [Debian](https://www.debian.org) instead of [Alpine](https://alpinelinux.org/) as base image for `psu`.
<!-- - `dev-debian` -> [`dev`](https://gitlab.com/psuapp/psu/-/tags/dev)
- `dev-debian-core` -> [`dev`](https://gitlab.com/psuapp/psu/-/tags/dev) -->
- `1-debian`, `1.3-debian`, `1.3.0-debian` -> [`v1.3.0`](https://gitlab.com/psuapp/psu/-/tags/v1.3.0)
- `1-debian-core`, `1.3-debian-core`, `1.3.0-debian-core` -> [`v1.3.0`](https://gitlab.com/psuapp/psu/-/tags/v1.3.0)
- `1.2-debian`, `1.2.0-debian` -> [`v1.2.0`](https://gitlab.com/psuapp/psu/-/tags/v1.2.0)
- `1.2-debian-core`, `1.2.0-debian-core` -> [`v1.2.0`](https://gitlab.com/psuapp/psu/-/tags/v1.2.0)
- `1.1-debian`, `1.1.0-debian` -> [`v1.1.0`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0)
- `1.1-debian-core`, `1.1.0-debian-core` -> [`v1.1.0`](https://gitlab.com/psuapp/psu/-/tags/v1.1.0)
- `1.0-debian`, `1.0.7-debian` -> [`v1.0.7`](https://gitlab.com/psuapp/psu/-/tags/v1.0.7)
- `1.0-debian-core`, `1.0.7-debian-core` -> [`v1.0.7`](https://gitlab.com/psuapp/psu/-/tags/v1.0.7)
##### Multi-Architecture
The Docker images support multi-architecture: `linux/amd64`, `linux/arm64` and `linux/arm/v7`.
On ARM machines, if you get this error when running a `psu` Docker image:
```
standard_init_linux.go:228: exec user process caused: exec format error
```
You need to install `linux/amd64` QEMU binary, like this:
```bash
docker run --privileged --rm tonistiigi/binfmt --install linux/amd64
```
Then run your `psu` Docker image again and it should work 🤞
And if you want to uninstall this QEMU binary, run this command:
```bash
docker run --privileged --rm tonistiigi/binfmt --uninstall linux/amd64
```
#### Testing/debugging:
For testing/debugging, you can use this Docker image in interactive mode, to run any commands inside the container:
```bash
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -it --rm --entrypoint bash psuapp/psu:1.3
# Run any commands here! E.g.
$ psu --version
Portainer Stack Utils, version 1.3.0
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](docs/README.md#available-options).
#### Examples
```bash
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
```
```bash
psu rm --user admin --password password --url https://portainer.local --name mystack
```
**With Docker:**
```bash
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env psuapp/psu:1.3 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](docs/README.md#available-options).
#### Examples
```bash
psu deploy -u admin -p password -l https://portainer.local -n mystack -c /path/to/docker-compose.yml -g /path/to/env_vars_file
```
```bash
psu rm -u admin -p password -l https://portainer.local -n mystack
```
**With Docker:**
```bash
docker run -v $(pwd)/docker-compose.yml:/docker-compose.yml -v $(pwd)/.env:/.env psuapp/psu:1.3 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](https://en.wikipedia.org/wiki/Continuous_integration)/[CD](https://en.wikipedia.org/wiki/Continuous_deployment) 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](docs/README.md#available-environment-variables).
#### Examples
```bash
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
```
```bash
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:**
```bash
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.3
```
## Documentation
<div class="docsify-hidden">
For advanced usage, see the full <a href="https://psuapp.gitlab.io/psu/1-3-stable"><abbr title="Portainer Stack Utils">PSU</abbr> documentation</a>.
</div>
For detailed instructions, see the [CLI Commands](docs/README.md) documentation.
## Supported Portainer API
<abbr title="Portainer Stack Utils">PSU</abbr> was created for the latest versions of Portainer API, which at the time of writing are [1.24.2](https://app.swaggerhub.com/apis/deviantony/Portainer/1.24.1), [2.5.1](https://app.swaggerhub.com/apis/portainer/portainer-ce/2.5.1), [2.6.3](https://app.swaggerhub.com/apis/portainer/portainer-ce/2.6.3) and [2.9.3](https://app.swaggerhub.com/apis/portainer/portainer-ce/2.9.3).
## License
Source code contained by this project is licensed under the [GNU General Public License version 3](https://www.gnu.org/licenses/gpl-3.0.en.html).
See [LICENSE](LICENSE) file for reference.
[Linux]: https://kernel.org
[Alpine]: https://alpinelinux.org
[Debian]: https://debian.org
[Ubuntu]: https://ubuntu.com/
[macOS]: https://apple.com/macos
[Homebrew]: https://brew.sh
[coreutils]: https://formulae.brew.sh/formula/coreutils
[Windows]: https://microsoft.com/windows
[bash]: https://www.gnu.org/software/bash
[curl]: https://curl.se
[jq]: https://stedolan.github.io/jq
[timeout]: https://man7.org/linux/man-pages/man1/timeout.1.html
[uuidgen]: https://man7.org/linux/man-pages/man1/uuidgen.1.html
[docker-compose]: https://docs.docker.com/compose/install
[git]: https://git-scm.com/