https://github.com/flweber/portainer-stack-updater
This tool can be used to update a stack via the portainer project.
https://github.com/flweber/portainer-stack-updater
cli nodejs portainer portainer-api portainer-update stack update
Last synced: 12 months ago
JSON representation
This tool can be used to update a stack via the portainer project.
- Host: GitHub
- URL: https://github.com/flweber/portainer-stack-updater
- Owner: flweber
- License: mit
- Archived: true
- Created: 2019-07-26T12:30:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T10:01:26.000Z (almost 2 years ago)
- Last Synced: 2025-03-17T03:17:26.896Z (about 1 year ago)
- Topics: cli, nodejs, portainer, portainer-api, portainer-update, stack, update
- Language: JavaScript
- Homepage: https://portainer-update.js.org/
- Size: 32.2 KB
- Stars: 5
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://ci.p.webish.one/job/portainer-stack-updater/job/master/)   [](https://github.com/flweber/portainer-stack-updater/issues)   [](https://github.com/flweber/portainer-stack-updater/blob/master/LICENSE)
# Portainer Update
This tool can be used to update a stack via the [portainer project](https://www.portainer.io/).
## Feature list
- [X] Update existing stacks
- [X] Read a docker-compose file from file system
- [X] Make tool available through npx
- [X] Deploy new stacks
- [X] Command line tool
## Usage
==Attention: Portainer only supports compose file version 2 at the moment==
### Example Usage
## As package
```javascript
const { Auth, Deploy, Update, GetStackByName } = require('portainer-update');
const url = "http://localhost:9000/api";
Auth("username", "password", url)
.then(async (response) => {
const stacks = [];
const stackid = await GetStackByName(response.jwt, url, "stackname");
// JsonWebToken, Portainer api url, id of stack which should be updated,
// endpoint id, docker compose as string
stacks.push(await Update(response.jwt, url, stackid, 1, "compose string"));
// JsonWebToken, Portainer api url, name of the new stack which will be deployed,
// endpoint id, docker compose as string
stacks.push(await Deploy(response.jwt, url, "stackname", 1, "compose string"));
console.info(JSON.stringify(stacks));
});
```
## In Terminal
```bash
npx portainer-update -p -u --password -f -s
```
### Parameters
|Parameter|Name|Description|Required|
|:--:|--|:--|:--:|
|-h \| --help|Help|Show this parameter table||
|-e \| --env|Envrionment|At the moment this parameter has no effect||
|-p \| --project|Stackname|The name of the stack you want to update|**X**|
|-u \| --user|Portainer Username|The username of the user which will update the stack ==The user need the permission to edit the stack==|**X**|
|--password|Portainer Password|This tool is for use in CiCD pipelines so please provide the password as a secret variable|**X**|
|-f \| --compose|Path to compose|Fill in the path to the compose file, which you want to deploy|**X**|
|-s \| --portainersystem|Portainer API URL|The address where to find portainer API (The url you are browsing to in your browser)|Default value: `http://localhost:9000`|
|--endpoint|Endpoint ID|The id of the endpoint where the stack should be deployed|Default value: `1`|