Sign inSign up

slocomptech/portainer-deployer

By slocomptech

Updated over 6 years ago

Portainer deployer service

Image
0

271

slocomptech/portainer-deployer repository overview

portainer-deployer

NodeJS application that deploys/updates portainer stack with new version of containers.

Usage

export PORTAINER_API="http://localhost:9000/api"

# Development
npm run start:dev

# Production
npm run start

# Development run commands
DISABLE_AUTH=1 PORTAINER_API=http://localhost:9000/api npm run start:dev
PORTAINER_API=http://localhost:9000/api npm run start:dev

Docker

Build
docker build -t <tag> .
Run
docker create \
  --name=deployer \
  -e PORTAINER_API="http://localhost:9000/api" \
  -e TZ=Europe/Ljubljana \
  -p 3000:3000 \
  --restart unless-stopped \
  slocomptech/portainer-deployer
Docker compose
version: "2"
services:
  portainer-deployer:
    image: slocomptech/portainer-deployer
    container_name: portainer-deployer
    environment:
      - PORTAINER_API="http://localhost:9000/api"
      - TZ=Europe/Ljubljana
    ports:
      - "3000:3000"
    restart: unless-stopped
Parameters
ParameterFunction
-e DISABLE_AUTH=trueDisable authentication
-e PORTAINER_API=http(s)://<url>/apiPortainer API URL (required)
-e PORTAINER_USER=<username>Portainer (default) username
-e PORTAINER_PASS=<password>Portainer (default) password
-e CONFIG=<path to config file>Custom config file path.
-e LOG_LEVEL=verboseEnable app output see docs
-e FAIL_MODE=hardWhat to do if services fail.
-e PUID=1000for UserID - see below for explanation
-e PGID=1000for GroupID - see below for explanation
-e SKIP_APP=trueDon't start app, useful for development.
-e TZ=Europe/LondonSpecify a timezone to use EG Europe/London.
-v <path>:/configAll the config files reside here.
-p 3000:3000Expose port

Request

Request metod is POST and depends on handler, but in general request looks like

{
  "handler": "default", /* Handler name, if omitted default is 'default' */
  "data": {
    /* Data send to handler */
  }
}
Authentication

Authenitcation of app is linked to portainer API login, so it hasn't any internal authentication mechanisms. But there are multiple ways of authentication:

  • Header Authorization: Bearer <Portainer auth token>
  • Header Authorization: Basic <base64 encoded user:pass>
  • No headers, set PORTAINER_USER, PORTAINER_PASS environment variables.
Handlers
Default handler

Default handler changes value of existing environment variables of stack and triggers redeploy.

{
  "data": {
    "stack": "<stack name>",
    "env": {
      "<varname>": "<value>"
    }
  }
}

Tag summary

Content type

Image

Digest

Size

128 MB

Last updated

over 6 years ago

docker pull slocomptech/portainer-deployer