├── files ├── st2-cli.conf ├── htpasswd ├── rbac │ ├── assignments │ │ ├── stanley.yaml │ │ └── st2admin.yaml │ └── roles │ │ └── sample.yaml ├── st2.user.conf ├── st2.docker.conf └── config.js ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── st2-docker.yml ├── .dockerignore ├── scripts ├── makesecrets.sh ├── st2client-startup.sh ├── st2chatops-startup.sh └── st2web-healthcheck.sh ├── .gitignore ├── tests ├── st2tests.yaml └── st2tests.bat ├── CHANGELOG.md ├── docker-compose.yml ├── LICENSE └── README.md /files/st2-cli.conf: -------------------------------------------------------------------------------- 1 | # /root/.st2/config 2 | [credentials] 3 | username = st2admin 4 | password = Ch@ngeMe 5 | -------------------------------------------------------------------------------- /files/htpasswd: -------------------------------------------------------------------------------- 1 | # /etc/st2/htpasswd 2 | # st2admin:Ch@ngeMe 3 | st2admin:$apr1$GjA7KmRf$nmbcSB1XoYRPfQrL9ZBD5. 4 | -------------------------------------------------------------------------------- /files/rbac/assignments/stanley.yaml: -------------------------------------------------------------------------------- 1 | # See: https://docs.stackstorm.com/rbac.html#defining-user-role-assignments 2 | --- 3 | username: stanley 4 | roles: 5 | - admin 6 | -------------------------------------------------------------------------------- /files/rbac/assignments/st2admin.yaml: -------------------------------------------------------------------------------- 1 | # See: https://docs.stackstorm.com/rbac.html#defining-user-role-assignments 2 | --- 3 | username: st2admin 4 | roles: 5 | - system_admin 6 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # https://stackstorm.com/2020/06/12/sponsoring-stackstorm/ 2 | # FAQ: https://stackstorm.com/donate/ 3 | # Expenses: https://github.com/StackStorm/discussions/issues/36 4 | community_bridge: stackstorm 5 | -------------------------------------------------------------------------------- /files/rbac/roles/sample.yaml: -------------------------------------------------------------------------------- 1 | # sample RBAC role file, see https://docs.stackstorm.com/rbac.html#defining-roles-and-permission-grants 2 | --- 3 | name: "sample" 4 | description: "Example Role which contains no permission grants and serves for demonstration purposes" 5 | -------------------------------------------------------------------------------- /files/st2.user.conf: -------------------------------------------------------------------------------- 1 | # /etc/st2/st2.user.conf 2 | # 3 | # This file is provided with no custom overrides and should be utilized by end-users to make any 4 | # desired configuration changes. No changes to this file should be checked into the st2-docker repository. 5 | # The order of merging: st2.conf < st2.docker.conf < st2.user.conf 6 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | *.md 2 | *.yml 3 | .DS_Store 4 | .circleci 5 | .git 6 | .gitignore 7 | .travis.yml 8 | packs.dev 9 | CHANGELOG.rst 10 | LICENSE 11 | Makefile 12 | conf 13 | 14 | ### JetBrains template 15 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 16 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 17 | .idea 18 | -------------------------------------------------------------------------------- /scripts/makesecrets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Generate st2 datastore crypto key on st2 startup 4 | # https://docs.stackstorm.com/datastore.html#securing-secrets-admin-only 5 | 6 | # this needs to run as root, so can't be ran in the st2api container 7 | KEYPATH=/etc/st2/keys/datastore_key.json 8 | if [ ! -f "${KEYPATH}" ]; then 9 | echo "Generating ${KEYPATH}" 10 | st2-generate-symmetric-crypto-key --key-path ${KEYPATH} 11 | chown -R st2:st2 /etc/st2/keys 12 | chmod -R 750 /etc/st2/keys 13 | fi 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve the stackstorm docker image 4 | 5 | --- 6 | 7 | **Describe the problem** 8 | A clear and concise description of what the problem is. 9 | 10 | **Versions** 11 | - Host OS: [e.g. Ubuntu 18.04] 12 | - docker: [e.g. 18.09.1-ce] 13 | - docker-compose: [e.g. 1.21.1] 14 | - stackstorm version: [e.g. v3.3.0] 15 | 16 | **To Reproduce** 17 | If necessary, please specify steps to reproduce the behavior. 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | -------------------------------------------------------------------------------- /scripts/st2client-startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | counter=0 4 | backoff=10 5 | 6 | # st2client startup and registration 7 | while [ "$counter" -lt 5 ]; do 8 | ACTIONS=$(st2 action list) 9 | if [ "$?" -ne 0 ]; then 10 | echo "unable to reach downstream, will try again in $backoff seconds..." 11 | sleep "$backoff" 12 | counter=$((counter+1)) 13 | backoff=$(awk -v backoff="$backoff" 'BEGIN{ printf "%.f", backoff * 1.5 }') 14 | elif [ "$ACTIONS" == "No matching items found" ]; then 15 | echo "No packs registered, will register" 16 | st2 pack register 17 | else 18 | echo "actions found st2client ready" 19 | sleep infinity 20 | fi 21 | done 22 | 23 | echo "Error! No packs were able to be registered due to st2 connect failures! You may need to load them manually." 24 | sleep infinity 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | packs 2 | packs.dev 3 | *.pyc 4 | conf 5 | 6 | ### JetBrains template 7 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 8 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 9 | .idea 10 | 11 | ### macOS template 12 | # General 13 | .DS_Store 14 | .AppleDouble 15 | .LSOverride 16 | 17 | # Icon must end with two \r 18 | Icon 19 | 20 | # Thumbnails 21 | ._* 22 | 23 | # Files that might appear in the root of a volume 24 | .DocumentRevisions-V100 25 | .fseventsd 26 | .Spotlight-V100 27 | .TemporaryItems 28 | .Trashes 29 | .VolumeIcon.icns 30 | .com.apple.timemachine.donotpresent 31 | 32 | # Directories potentially created on remote AFP share 33 | .AppleDB 34 | .AppleDesktop 35 | Network Trash Folder 36 | Temporary Items 37 | .apdisk 38 | -------------------------------------------------------------------------------- /scripts/st2chatops-startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # check for chatops env enabled 4 | if [[ -z "$ST2_CHATOPS_ENABLE" ]] || [[ "$ST2_CHATOPS_ENABLE" == "0" ]] ; then 5 | echo "chatops service is not enabled, exiting." 6 | exit 0 7 | fi 8 | 9 | # wait for the st2 api to be up before starting hubot 10 | while true ; do 11 | API_UP=$(curl -s -o /dev/null -m 10 --connect-timeout 5 ${ST2_API_URL}) 12 | if [[ $? -ne 0 ]] ; then 13 | echo "st2api not yet available, waiting for retry..." 14 | sleep 5 15 | else 16 | echo "st2api is ready, starting hubot..." 17 | break 18 | fi 19 | done 20 | 21 | # test hubot's config before attempting to start 22 | echo "Testing hubot configuration..." 23 | bin/hubot --config-check 24 | 25 | if [[ $? -ne 0 ]] ; then 26 | echo "WARNING: hubot --config-check failed, are your adapter variables configured properly?" 27 | exit 1 28 | fi 29 | 30 | # start hubot 31 | echo "Starting hubot..." 32 | bin/hubot 33 | -------------------------------------------------------------------------------- /files/st2.docker.conf: -------------------------------------------------------------------------------- 1 | # /etc/st2/st2.docker.conf 2 | # 3 | # This st2.docker.conf overrides st2.conf in the base image, and has been written to facilitate operation of 4 | # docker-compose.yml. It is recommended to not alter this file as an end-user, as this file 5 | # is updated as necessary by the StackStorm st2-docker maintainers. 6 | # Instead, make local changes in the file "st2.user.conf". 7 | # The order of merging: st2.conf < st2.docker.conf < st2.user.conf 8 | [auth] 9 | api_url = http://st2api:9101/ 10 | 11 | [messaging] 12 | url = amqp://guest:guest@rabbitmq:5672 13 | 14 | [keyvalue] 15 | encryption_key_path = /etc/st2/keys/datastore_key.json 16 | 17 | [database] 18 | host = mongo 19 | # st2.conf for kubernetes disables retry (relying on kubernetes), but 20 | # for straight docker, we want to re-enable these. 21 | # Connection retry total time (minutes). 22 | connection_retry_max_delay_m = 1 23 | # Backoff multiplier (seconds). 24 | connection_retry_backoff_mul = 1 25 | # Connection and server selection timeout (in ms). 26 | connection_timeout = 3000 27 | 28 | [content] 29 | packs_base_paths=/opt/stackstorm/packs.dev 30 | 31 | [coordination] 32 | url = redis://redis:6379 33 | -------------------------------------------------------------------------------- /files/config.js: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The StackStorm Authors. 2 | // Copyright 2019 Extreme Networks, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | 'use strict'; 17 | 18 | /* global angular */ 19 | angular.module('main') 20 | .constant('st2Config', { 21 | 22 | //show_version_in_header: true, 23 | 24 | // hosts: [ 25 | // { 26 | // name: 'Dev Env', 27 | // url: 'https://:443/api', 28 | // auth: 'https://:443/auth', 29 | // stream: 'https://:443/stream', 30 | // }, 31 | // { 32 | // name: 'Express', 33 | // url: '//172.168.90.50:9101/api', 34 | // auth: '//172.168.90.50:9101/auth', 35 | // }, 36 | // ], 37 | }); 38 | 39 | -------------------------------------------------------------------------------- /.github/workflows/st2-docker.yml: -------------------------------------------------------------------------------- 1 | name: st2-docker 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | - master 9 | schedule: 10 | - cron: 0 1 * * * 11 | workflow_dispatch: 12 | 13 | jobs: 14 | docker-compose-lint: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v3 18 | 19 | - name: Docker-compose lint check 20 | run: docker compose config 21 | 22 | docker-compose-up: 23 | runs-on: ubuntu-latest 24 | needs: [docker-compose-lint] 25 | steps: 26 | - uses: actions/checkout@v3 27 | 28 | - name: Pull Docker Images 29 | run: | 30 | docker compose pull 31 | 32 | - name: Start st2 with docker compose 33 | run: | 34 | docker compose up --detach 35 | 36 | - name: Sleep 37 | run: | 38 | sleep 60 39 | 40 | - name: Run st2 smoke-tests 41 | run: | 42 | docker compose --file tests/st2tests.yaml run st2test 43 | 44 | - name: Troubleshooting the build failure 45 | if: ${{ failure() }} 46 | run: | 47 | docker compose ps 48 | # Display logs to help troubleshoot build failures, etc 49 | docker compose logs --tail="500" st2api 50 | exit 1 51 | -------------------------------------------------------------------------------- /tests/st2tests.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | st2test: 5 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2actionrunner:${ST2_VERSION:-latest} 6 | environment: 7 | ST2_AUTH_URL: ${ST2_AUTH_URL:-http://st2auth:9100/} 8 | ST2_API_URL: ${ST2_API_URL:-http://st2api:9101/} 9 | ST2_STREAM_URL: ${ST2_STREAM_URL:-http://st2stream:9102/} 10 | ST2WEB_HTTPS: ${ST2WEB_HTTPS:-0} 11 | ST2_AUTH_USERNAME: ${ST2_AUTH_USERNAME:-st2admin} 12 | ST2_AUTH_PASSWORD: ${ST2_AUTH_PASSWORD:-Ch@ngeMe} 13 | command: 14 | - bash 15 | - -ec 16 | - | 17 | apt update > /dev/null 2>&1 18 | apt install bats -y > /dev/null 2>&1 19 | mkdir /tools 20 | git clone --config advice.detachedHead=false --depth 1 --branch v0.3.0 \ 21 | https://github.com/ztombol/bats-assert /tools/bats-assert > /dev/null 2>&1 22 | git clone --config advice.detachedHead=false --depth 1 --branch v0.2.0 \ 23 | https://github.com/ztombol/bats-file /tools/bats-file > /dev/null 2>&1 24 | git clone --config advice.detachedHead=false --depth 1 --branch v0.3.0 \ 25 | https://github.com/ztombol/bats-support /tools/bats-support > /dev/null 2>&1 26 | bats /opt/stackstorm/st2tests.bat 27 | volumes: 28 | - ./st2tests.bat:/opt/stackstorm/st2tests.bat:ro 29 | networks: 30 | - st2-docker_private 31 | stop_signal: SIGKILL 32 | 33 | networks: 34 | st2-docker_private: 35 | external: true 36 | -------------------------------------------------------------------------------- /scripts/st2web-healthcheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # A set of scripts to ensure st2web service liveness 4 | 5 | # check downstream services and mark container unhealthy if downstream is not unreachable 6 | DOWNSTREAM_API_STATUS=$(curl --write-out "%{http_code}\n" --silent --output /dev/null $ST2_API_URL/v1) 7 | if [ "${DOWNSTREAM_API_STATUS}" != "404" ]; then 8 | echo "st2api downstream failure"; exit 1; 9 | fi 10 | DOWNSTREAM_STREAM_STATUS=$(curl --write-out "%{http_code}\n" --silent --output /dev/null $ST2_STREAM_URL/v1/stream) 11 | if [ "${DOWNSTREAM_STREAM_STATUS}" != "404" ]; then 12 | echo "st2stream downstream failure"; exit 1; 13 | fi 14 | DOWNSTREAM_AUTH_STATUS=$(curl --write-out "%{http_code}\n" --silent --output /dev/null $ST2_AUTH_URL/v1) 15 | if [ "${DOWNSTREAM_AUTH_STATUS}" != "404" ]; then 16 | echo "st2auth downstream failure"; exit 1; 17 | fi 18 | 19 | # Check each service through the nginx reverse proxy for a specific return code. If the curl request 20 | # fails to work through nginx, a stop signal will be sent to nginx, causing the container to restart. 21 | API_STATUS=$(curl --write-out "%{http_code}\n" --silent --output /dev/null http://localhost/api/v1/) 22 | if [ "${API_STATUS}" != "401" ]; then 23 | echo "st2api nginx failure"; nginx -s stop; 24 | fi 25 | STREAM_STATUS=$(curl --write-out "%{http_code}\n" --silent --output /dev/null http://localhost/stream/v1/stream) 26 | if [ "${STREAM_STATUS}" != "401" ]; then 27 | echo "st2stream nginx failure"; nginx -s stop; 28 | fi 29 | AUTH_STATUS=$(curl --write-out "%{http_code}\n" --silent --output /dev/null http://localhost/auth/v1/) 30 | if [ "${AUTH_STATUS}" != "404" ]; then 31 | echo "st2auth nginx failure"; nginx -s stop; 32 | fi 33 | 34 | exit 0 35 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 2023-11-07 4 | * Upgrade to RabbitMQ v3.12 5 | * Upgrade to Redis v7.2 6 | 7 | ## 2023-10-28 8 | * Refactor st2test, install BATS via `apt install` 9 | * Remove unneeded file st2test-tools.sh 10 | * Fix ST2_AUTH_URL and ST2_STREAM_URL 11 | 12 | ## 2022-05-06 13 | * Migrate to Ubuntu 20 / Python 3.8 based containers 14 | 15 | ## 2022-05-04 16 | * Upgrade MongoDB `v4.0` -> `v4.4` as 4.0 has reached its EOL. (#243) 17 | * Fix stackstorm-ssh volume mount path in docker-compose.yml st2actionrunner service (#244) 18 | 19 | ## 2021-12-02 20 | * Removed `dns_search: .` from all services in `docker-compose.yml` per discussion in #231 21 | 22 | ## 2021-04-15 23 | * Add BATS testing 24 | 25 | ## 2021-04-10 26 | * Upgrade used Redis Docker image to 6.2. 27 | 28 | ## 2021-04-07 29 | * Add rbac sample files and mount to st2api and st2client (#219) 30 | 31 | ## 2021-04-06 32 | * Add information on how to utilize a custom config with st2web container. (#225) 33 | 34 | ## 2021-03-22 35 | * Create counter for st2client startup script (#220) 36 | 37 | ## 2021-03-15 38 | * Added `st2chatops` support and service startup script. (#206) 39 | 40 | ## 2021-03-13 41 | * Switch to using `latest` tag for st2 Docker images (#222) 42 | 43 | ## 2021-02-21 44 | * Add stackstorm-keys volume to workflowengine (#214) 45 | 46 | ## 2020-11-05 47 | * Deprecate st2resultstracker which is obsolete since the Mistral deprecation with st2 `v3.3.0`. 48 | 49 | ## 2020-11-03 50 | * Update st2 configuration to use redis as coordination backend. (#195) 51 | 52 | ## 2020-07-17 53 | * Replace docker-compose with a new deployment based on [stackstorm/st2-dockerfiles](https://github.com/StackStorm/st2-dockerfiles/) images relying on `Ubuntu Bionic` and `python 3` since st2 `v3.3dev` (#192) 54 | 55 | ## 2020-05-26 56 | * Deprecate demo all-in-one docker-compose deployment based on outdated `Ubuntu Trusty` with `python 2`, unsupported since st2 `v3.1.0` (#191) 57 | 58 | ## 2018-06-28 59 | * Add `st2workflowengine` to `entrypoint-1ppc.sh` and `compose-1ppc/docker-compose.yml`. 60 | 61 | ## 2018-06-18 62 | * The `TAG` environment variable is replaced by `ST2_IMAGE_TAG`. 63 | 64 | ## 2018-02-27 65 | * Pin DB's to specific, tested versions. 66 | 67 | ## 2017-10-23 68 | * Rename `/entrypoint.d/` to `/st2-docker/entrypoint.d/`. 69 | -------------------------------------------------------------------------------- /tests/st2tests.bat: -------------------------------------------------------------------------------- 1 | # bats smoke-tests 2 | 3 | load "/tools/bats-support/load.bash" 4 | load "/tools/bats-assert/load.bash" 5 | load "/tools/bats-file/load.bash" 6 | 7 | @test 'st2 version deployed and python env are as expected' { 8 | run st2 --version 9 | assert_success 10 | # st2 3.8.0, on Python 3.8.10 11 | assert_line --partial "st2 ${ST2_VERSION}" 12 | assert_line --partial 'on Python 3.8.10' 13 | } 14 | 15 | @test 'ST2_AUTH_URL service endpoint is accessible and working' { 16 | run curl -v ${ST2_AUTH_URL} 17 | assert_line --partial 'Content-Type: application/json' 18 | assert_line --partial 'St2-Api-Key' 19 | } 20 | 21 | @test 'ST2_API_URL service endpoint is accessible and working' { 22 | run curl -v ${ST2_API_URL} 23 | assert_line --partial 'Content-Type: application/json' 24 | assert_line --partial 'St2-Api-Key' 25 | } 26 | 27 | @test 'ST2_STREAM_URL service endpoint is accessible and working' { 28 | run curl -v ${ST2_STREAM_URL} 29 | assert_line --partial 'Content-Type: application/json' 30 | assert_line --partial 'St2-Api-Key' 31 | } 32 | 33 | @test 'st2 user can log in with auth credentials' { 34 | run st2 login ${ST2_AUTH_USERNAME} --password ${ST2_AUTH_PASSWORD} -w 35 | assert_success 36 | assert_line "Logged in as ${ST2_AUTH_USERNAME}" 37 | assert_file_exist ~/.st2/config 38 | } 39 | 40 | @test 'st2 core pack is installed and loaded' { 41 | run st2 action list --pack=core 42 | assert_success 43 | assert_line --partial 'core.local' 44 | } 45 | 46 | @test "can execute simple st2 action 'core.local'" { 47 | run st2 run core.local cmd=id 48 | assert_success 49 | assert_line --partial 'return_code: 0' 50 | assert_line --partial "stderr: ''" 51 | assert_line --partial 'stdout: uid=1000(stanley) gid=1000(stanley) groups=1000(stanley)' 52 | assert_line --partial 'succeeded: true' 53 | } 54 | 55 | @test 'st2 chatops core rule is loaded' { 56 | run st2 rule list 57 | assert_success 58 | assert_line --partial 'chatops.notify' 59 | } 60 | 61 | @test 'st2 key/value operations are functional' { 62 | run st2 key set foo bar 63 | assert_success 64 | 65 | run st2 key get foo 66 | assert_success 67 | assert_line --partial 'bar' 68 | 69 | run st2 key delete foo 70 | assert_line --partial '"foo" has been successfully deleted' 71 | assert_success 72 | 73 | run st2 key get foo 74 | assert_line --partial '"foo" is not found' 75 | assert_failure 76 | } 77 | 78 | # TODO: RBAC isn't loaded automatically for st2-docker. Uncomment when/if RBAC is loaded on startup 79 | #@test 'RBAC is loaded and enabled' { 80 | # if [ $ST2_RBAC_ENABLED != "true" ]; then 81 | # skip "disabled in Helm values" 82 | # fi 83 | # 84 | # run st2 whoami 85 | # assert_success 86 | # assert_output --regexp 'RBAC:\s+ - Enabled: True' 87 | # assert_line --partial 'Roles: system_admin' 88 | #} 89 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | st2web: 5 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2web:${ST2_VERSION:-latest} 6 | restart: on-failure 7 | environment: 8 | ST2_AUTH_URL: ${ST2_AUTH_URL:-http://st2auth:9100/} 9 | ST2_API_URL: ${ST2_API_URL:-http://st2api:9101/} 10 | ST2_STREAM_URL: ${ST2_STREAM_URL:-http://st2stream:9102/} 11 | ST2WEB_HTTPS: ${ST2WEB_HTTPS:-0} 12 | depends_on: 13 | - st2auth 14 | - st2api 15 | - st2stream 16 | healthcheck: 17 | test: ["CMD", "/st2web-healthcheck.sh"] 18 | interval: 30s 19 | timeout: 1s 20 | retries: 1 21 | volumes: 22 | - ./scripts/st2web-healthcheck.sh:/st2web-healthcheck.sh 23 | # If you want to use a custom st2web config, edit ./files/config.js accordingly and 24 | # uncomment the line below 25 | #- ./files/config.js:/opt/stackstorm/static/webui/config.js:ro 26 | ports: 27 | - "${ST2_EXPOSE_HTTP:-127.0.0.1:80}:80" 28 | # - "${ST2_EXPOSE_HTTPS:-127.0.0.1:443}:443" 29 | # more work would be needed with certificate generate to make https work. 30 | networks: 31 | - private 32 | - public 33 | st2makesecrets: 34 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2actionrunner:${ST2_VERSION:-latest} 35 | restart: on-failure 36 | networks: 37 | - private 38 | volumes: 39 | - ./scripts/makesecrets.sh:/makesecrets.sh 40 | - stackstorm-keys:/etc/st2/keys:rw 41 | command: /makesecrets.sh 42 | st2api: 43 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2api:${ST2_VERSION:-latest} 44 | restart: on-failure 45 | depends_on: 46 | - mongo 47 | - rabbitmq 48 | - redis 49 | - st2makesecrets 50 | networks: 51 | - private 52 | environment: 53 | ST2_AUTH_URL: ${ST2_AUTH_URL:-http://st2auth:9100/} 54 | ST2_API_URL: ${ST2_API_URL:-http://st2api:9101/} 55 | ST2_STREAM_URL: ${ST2_STREAM_URL:-http://st2stream:9102/} 56 | volumes: 57 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 58 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 59 | - stackstorm-keys:/etc/st2/keys:ro 60 | - stackstorm-packs-configs:/opt/stackstorm/configs:rw 61 | - stackstorm-packs:/opt/stackstorm/packs:rw 62 | - ./files/rbac:/opt/stackstorm/rbac:rw 63 | - ${ST2_PACKS_DEV:-./packs.dev}:/opt/stackstorm/packs.dev:rw 64 | st2stream: 65 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2stream:${ST2_VERSION:-latest} 66 | restart: on-failure 67 | depends_on: 68 | - st2api 69 | networks: 70 | - private 71 | volumes: 72 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 73 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 74 | st2scheduler: 75 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2scheduler:${ST2_VERSION:-latest} 76 | restart: on-failure 77 | depends_on: 78 | - redis 79 | - st2api 80 | networks: 81 | - private 82 | volumes: 83 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 84 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 85 | st2workflowengine: 86 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2workflowengine:${ST2_VERSION:-latest} 87 | restart: on-failure 88 | depends_on: 89 | - redis 90 | - st2api 91 | networks: 92 | - private 93 | volumes: 94 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 95 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 96 | - stackstorm-keys:/etc/st2/keys:ro 97 | st2auth: 98 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2auth:${ST2_VERSION:-latest} 99 | restart: on-failure 100 | depends_on: 101 | - st2api 102 | networks: 103 | - private 104 | volumes: 105 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 106 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 107 | - ./files/htpasswd:/etc/st2/htpasswd:ro 108 | st2actionrunner: 109 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2actionrunner:${ST2_VERSION:-latest} 110 | restart: on-failure 111 | depends_on: 112 | - redis 113 | - st2api 114 | networks: 115 | - private 116 | volumes: 117 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 118 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 119 | - stackstorm-packs-configs:/opt/stackstorm/configs:rw 120 | - stackstorm-packs:/opt/stackstorm/packs:rw 121 | - ${ST2_PACKS_DEV:-./packs.dev}:/opt/stackstorm/packs.dev:rw 122 | - stackstorm-virtualenvs:/opt/stackstorm/virtualenvs:rw 123 | - stackstorm-ssh:/home/stanley/.ssh 124 | # Action runner needs access to keys since action definitions (Jinja 125 | # templates) can reference secrets 126 | - stackstorm-keys:/etc/st2/keys:ro 127 | st2garbagecollector: 128 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2garbagecollector:${ST2_VERSION:-latest} 129 | restart: on-failure 130 | depends_on: 131 | - st2api 132 | networks: 133 | - private 134 | volumes: 135 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 136 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 137 | st2notifier: 138 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2notifier:${ST2_VERSION:-latest} 139 | restart: on-failure 140 | depends_on: 141 | - redis 142 | - st2api 143 | networks: 144 | - private 145 | volumes: 146 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 147 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 148 | st2rulesengine: 149 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2rulesengine:${ST2_VERSION:-latest} 150 | restart: on-failure 151 | depends_on: 152 | - st2api 153 | networks: 154 | - private 155 | volumes: 156 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 157 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 158 | st2sensorcontainer: 159 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2sensorcontainer:${ST2_VERSION:-latest} 160 | restart: on-failure 161 | depends_on: 162 | - st2api 163 | networks: 164 | - private 165 | volumes: 166 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 167 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 168 | - stackstorm-virtualenvs:/opt/stackstorm/virtualenvs:ro 169 | - stackstorm-packs:/opt/stackstorm/packs:ro 170 | - stackstorm-packs-configs:/opt/stackstorm/configs:ro 171 | - ${ST2_PACKS_DEV:-./packs.dev}:/opt/stackstorm/packs.dev:ro 172 | st2timersengine: 173 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2timersengine:${ST2_VERSION:-latest} 174 | restart: on-failure 175 | depends_on: 176 | - st2api 177 | networks: 178 | - private 179 | volumes: 180 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 181 | st2client: 182 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2actionrunner:${ST2_VERSION:-latest} 183 | restart: on-failure 184 | depends_on: 185 | - st2auth 186 | - st2api 187 | - st2stream 188 | command: /st2client-startup.sh 189 | networks: 190 | - private 191 | environment: 192 | ST2CLIENT: 1 193 | ST2_AUTH_URL: ${ST2_AUTH_URL:-http://st2auth:9100/} 194 | ST2_API_URL: ${ST2_API_URL:-http://st2api:9101/} 195 | ST2_STREAM_URL: ${ST2_STREAM_URL:-http://st2stream:9102/} 196 | TZ: ${TZ:-UTC} 197 | volumes: 198 | - ./files/st2.docker.conf:/etc/st2/st2.docker.conf:ro 199 | - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 200 | # Technically, client container doesn't need or should have access to the 201 | # keys in prod setup, but here we make it available to end user for 202 | # testing and transparency reasons since this setup is primarily mean to 203 | # be used for testing and development. 204 | - stackstorm-keys:/etc/st2/keys:ro 205 | - stackstorm-packs-configs:/opt/stackstorm/configs:rw 206 | - stackstorm-packs:/opt/stackstorm/packs:rw 207 | - ./files/rbac:/opt/stackstorm/rbac:rw 208 | - ${ST2_PACKS_DEV:-./packs.dev}:/opt/stackstorm/packs.dev:rw 209 | - ./files/st2-cli.conf:/root/.st2/config 210 | - ./scripts/st2client-startup.sh:/st2client-startup.sh 211 | st2chatops: 212 | image: ${ST2_IMAGE_REPO:-stackstorm/}st2chatops:${ST2_VERSION:-latest} 213 | restart: on-failure:5 214 | depends_on: 215 | - st2api 216 | - st2auth 217 | - st2stream 218 | command: /st2chatops-startup.sh 219 | networks: 220 | - private 221 | environment: 222 | ST2_AUTH_URL: ${ST2_AUTH_URL:-http://st2auth:9100/} 223 | ST2_API_URL: ${ST2_API_URL:-http://st2api:9101/} 224 | ST2_STREAM_URL: ${ST2_STREAM_URL:-http://st2stream:9102/} 225 | ST2_API_KEY: ${ST2_API_KEY:-change-to-your-st2-api-key} 226 | TZ: ${TZ:-UTC} 227 | # enable chatops by setting this variable to any non-zero value 228 | # and enable/set your hubot adapter specific variables below 229 | ST2_CHATOPS_ENABLE: ${ST2_CHATOPS_ENABLE:-0} 230 | # Custom hubot adapter ENV variables to pass through which will override st2chatops.env defaults. 231 | # See https://github.com/StackStorm/st2chatops/blob/master/st2chatops.env 232 | # for the full list of supported adapters and example ENV variables. 233 | HUBOT_ADAPTER: ${HUBOT_ADAPTER:-slack} 234 | HUBOT_LOG_LEVEL: ${HUBOT_LOG_LEVEL:-debug} 235 | HUBOT_SLACK_TOKEN: ${HUBOT_SLACK_TOKEN:-} 236 | volumes: 237 | - ./scripts/st2chatops-startup.sh:/st2chatops-startup.sh 238 | # external services 239 | mongo: 240 | image: mongo:4.4 241 | restart: on-failure 242 | networks: 243 | - private 244 | volumes: 245 | - stackstorm-mongodb:/data/db 246 | rabbitmq: 247 | image: rabbitmq:3.12 248 | restart: on-failure 249 | networks: 250 | - private 251 | volumes: 252 | - stackstorm-rabbitmq:/var/lib/rabbitmq 253 | redis: 254 | image: redis:7.2 255 | restart: on-failure 256 | networks: 257 | - private 258 | volumes: 259 | - stackstorm-redis:/data 260 | 261 | volumes: 262 | stackstorm-mongodb: 263 | stackstorm-rabbitmq: 264 | stackstorm-redis: 265 | stackstorm-packs: 266 | stackstorm-packs-configs: 267 | stackstorm-keys: 268 | stackstorm-virtualenvs: 269 | stackstorm-ssh: 270 | 271 | networks: 272 | public: 273 | driver: bridge 274 | private: 275 | driver: bridge 276 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2020 The StackStorm Authors. 190 | Copyright 2017 StackStorm, Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # StackStorm in Docker Compose 2 | 3 | [![CI Build Status](https://github.com/StackStorm/st2-docker/actions/workflows/st2-docker.yml/badge.svg)](https://github.com/StackStorm/st2-docker/actions/workflows/st2-docker.yml) 4 | 5 | This docker-compose is provided as a way to allow "get up and running" quickly with StackStorm using Docker (based on [st2-dockerfiles](https://github.com/stackstorm/st2-dockerfiles)). It is not designed to be used in production, but rather a way to test out StackStorm and facilitate pack development. 6 | > If you need Highly Availability experience, there is Kubernetes installation available via Helm charts at https://docs.stackstorm.com/install/k8s_ha.html. 7 | 8 | ## TL;DR 9 | 10 | ```shell 11 | docker-compose up -d 12 | docker-compose exec st2client bash # this gives you access to the st2 command line 13 | ``` 14 | 15 | Open `http://localhost/` in your browser. StackStorm Username/Password by default is: `st2admin/Ch@ngeMe`. 16 | 17 | ## Usage 18 | 19 | ### Prerequisites 20 | 21 | - Docker Engine 18.09+ 22 | - Docker Compose 1.12+ 23 | 24 | ### Compose Configuration 25 | 26 | The image version, exposed ports, chatops, and "packs.dev" directory are configurable with environment variables. 27 | 28 | - **ST2_VERSION** this is the tag at the end of the docker image (ie: stackstorm/st2api:v3.3.0) 29 | - **ST2_IMAGE_REPO** The image or path to the images. Default is "stackstorm/". You may change this is using the Enterprise version or a private docker repository. 30 | - **ST2_EXPOSE_HTTP** Port to expose st2web port 80 on. Default is `127.0.0.1:80`, and you may want to do `0.0.0.0:80` to expose on all interfaces. 31 | - **ST2_PACKS_DEV** Directory to development packs, absolute or relative to docker-compose.yml. This allows you to develop packs locally. Default is `./packs.dev`. When making a number of packs, it is recommended to make a directory outside of st2-docker, with each subdirectory underneath that being an independent git repo. Example: `ST2_PACKS_DEV=${HOME}/mypacks`, with `${HOME}/mypacks/st2-helloworld` being a git repo for the "helloworld" pack. 32 | - **ST2_CHATOPS_ENABLE** To enable chatops, set this variable to any non-zero value. Also ensure that your environment settings are configured for your chatops adapter (see the `st2chatops` service `environment` comments/settings for more info) 33 | - **HUBOT_ADAPTER** Chat service adapter to use (see https://docs.stackstorm.com/chatops/) 34 | - **HUBOT_SLACK_TOKEN** If using the [Slack](https://github.com/slackapi/hubot-slack) adapter, this is your "Bot User OAuth Access Token" 35 | 36 | ### Credentials 37 | 38 | The `files/htpasswd` file is provided with a default username of `st2admin` and a default password of `Ch@ngeMe`. This can be changed using the [htpasswd utility](https://httpd.apache.org/docs/2.4/programs/htpasswd.html). 39 | 40 | Another file (`files/st2-cli.conf`) contains default credentials and is mounted into the "st2client" container. If you change credentials in htpasswd, you will probably want to change them in `st2-cli.conf`. 41 | 42 | ### Further configuration 43 | 44 | The base st2 docker images have a built-in `/etc/st2/st2.conf` configuration file. Each st2 Docker image will load: 45 | 46 | - /etc/st2/st2.conf (default [st2.conf](https://github.com/StackStorm/st2/blob/master/conf/st2.package.conf)) 47 | - /etc/st2/st2.docker.conf (values here will override st2.conf) 48 | - /etc/st2/st2.user.conf (values here will override st2.docker.conf) 49 | 50 | Review `st2.docker.conf` for currently set values, and it is recommended to place overrides in `st2.user.conf`. 51 | 52 | If you want to utilize a custom config for StackStorm Web UI (st2web container), you can do that by editing 53 | `files/config.js` file and mounting it as a volume inside the container as per example in `docker-compose.yml`. 54 | 55 | #### Chatops configuration 56 | 57 | Chatops settings are configured in the `environment` section for the `st2chatops` service in `docker-compose.yml` 58 | 59 | Set `ST2_CHATOPS_ENABLE` to any non-zero value, then edit the various `HUBOT_` variables specific to your chatops adapter. 60 | See https://github.com/StackStorm/st2chatops/blob/master/st2chatops.env for the full list of supported adapters and example ENV variables. 61 | 62 | You will also need an st2 API key for chatops. This should be set in `ST2_API_KEY`. 63 | 64 | To generate an API key, see the [StackStorm documentation](https://docs.stackstorm.com/authentication.html#api-keys). 65 | 66 | _Note:_ If you are standing up st2 for the first time, you may first need to start with chatops initially disabled so you can generate 67 | an API key. Once this is done, set it in `ST2_API_KEY`, enable chatops as per above and `docker-compose restart` to 68 | restart your st2 stack. 69 | 70 | #### RBAC Configuration 71 | 72 | Starting with v3.4.0 RBAC is now included, but not enabled, by default. There are some default assignments, mappings, and roles 73 | that ship with st2-docker. All the configuration files for RBAC are kept in `./files/rbac`. 74 | Consult the [st2 RBAC documentation](https://docs.stackstorm.com/rbac.html) for further information. 75 | 76 | To enable RBAC you can edit st2.user.conf and add the following options: 77 | ```ini 78 | [rbac] 79 | enable = True 80 | backend = default 81 | ``` 82 | 83 | Any changes made to RBAC assignments, mappings, or roles have to be synced in order to take effect. Normally running `st2-apply-rbac-definitions` 84 | will sync the files, but because all database information is not in the standard st2.conf file you need to specify the config file 85 | 86 | To sync RBAC changes in st2client: 87 | ```shell 88 | st2-apply-rbac-definitions --config-file /etc/st2/st2.docker.conf 89 | ```` 90 | 91 | LDAP is also a feature that is now included, but not enabled, by default. Roles to LDAP groups can be configured in `./files/rbac/mappings`. 92 | Consult the [st2 LDAP documentation](https://docs.stackstorm.com/authentication.html#ldap) for further information 93 | 94 | 95 | ### Step by step first time instructions 96 | 97 | First, optionally set and export all the environment variables you want to change. You could make an `.env` file with customizations. 98 | 99 | Example: 100 | 101 | ```shell 102 | export ST2_PACKS_DEV=$HOME/projects/stackstorm-packs 103 | export ST2_EXPOSE_HTTP=0.0.0.0:80 104 | export ST2_CHATOPS_ENABLE=1 105 | export HUBOT_SLACK_TOKEN=xoxb-MY-SLACK-TOKEN 106 | ``` 107 | 108 | Secondly make any customizations to `files/st2.user.conf`, `files/htpasswd`, and `files/st2-cli.conf`. 109 | 110 | Example: 111 | 112 | To enable [sharing code between actions and sensors](https://docs.stackstorm.com/reference/sharing_code_sensors_actions.html), add these two lines to `files/st2.user.conf`: 113 | 114 | ```ini 115 | [packs] 116 | enable_common_libs = True 117 | ``` 118 | 119 | Third, start the docker environment: 120 | 121 | ```shell 122 | docker-compose up -d 123 | ``` 124 | 125 | This will pull the required images from docker hub, and then start them. 126 | 127 | To stop the docker environment, run: 128 | 129 | ```shell 130 | docker-compose down 131 | ``` 132 | 133 | ### Gotchas 134 | 135 | #### Startup errors 136 | 137 | If your system has SELinux enabled you will likely see problems with st2 startup, specifically 138 | the `st2makesecrets` container will repeatedly restart and `docker logs` shows: 139 | 140 | ```/bin/bash: /makesecrets.sh: Permission denied``` 141 | 142 | The fix is to disable SELinux (or to put it in permissive mode). 143 | 144 | * Disable temporarily with: `setenforce 0` 145 | * Change to use permissive mode on the next reboot with: `sed -ie 's|^SELINUX=.*|SELINUX=permissive|' /etc/selinux/config` 146 | 147 | #### Chatops 148 | 149 | * Chatops has been minimally tested using the Slack hubot adapter. Other adapter types may require some 150 | tweaking to the environment settings for the `st2chatops` service in `docker-compose.yml` 151 | 152 | * The git status output on the `!packs get` command doesn't appear to work fully. 153 | 154 | * Use `docker-compose logs st2chatops` to check the chatops logs if you are having problems getting chatops to work 155 | 156 | ## Regular Usage 157 | 158 | To run st2 commands, you can use the st2client service: 159 | 160 | ```shell 161 | docker-compose exec st2client st2 162 | ``` 163 | 164 | Example: 165 | 166 | ```shell 167 | $ docker-compose exec st2client st2 run core.echo message=hello 168 | . 169 | id: 5eb30d77afe5aa8493f31187 170 | action.ref: core.echo 171 | context.user: st2admin 172 | parameters: 173 | message: hello 174 | status: succeeded 175 | start_timestamp: Wed, 06 May 2020 19:18:15 UTC 176 | end_timestamp: Wed, 06 May 2020 19:18:15 UTC 177 | result: 178 | failed: false 179 | return_code: 0 180 | stderr: '' 181 | stdout: hello 182 | succeeded: true 183 | ``` 184 | 185 | Alternatively, you could run `docker-compose exec st2client bash` to be dropped into a container with st2. At that point, you can just run `st2` commands. 186 | 187 | Example: 188 | 189 | ```shell 190 | $ docker-compose exec st2client bash 191 | Welcome to StackStorm v3.3.0 (Ubuntu 18.04.4 LTS GNU/Linux x86_64) 192 | * Documentation: https://docs.stackstorm.com/ 193 | * Community: https://stackstorm.com/community-signup 194 | * Forum: https://forum.stackstorm.com/ 195 | 196 | Here you can use StackStorm CLI. Examples: 197 | st2 action list --pack=core 198 | st2 run core.local cmd=date 199 | st2 run core.local_sudo cmd='apt-get update' --tail 200 | st2 execution list 201 | 202 | root@aaabd11745f0:/opt/stackstorm# st2 run core.echo message="from the inside" 203 | . 204 | id: 5eb310f571af8f57a4582430 205 | action.ref: core.echo 206 | context.user: st2admin 207 | parameters: 208 | message: from the inside 209 | status: succeeded 210 | start_timestamp: Wed, 06 May 2020 19:33:09 UTC 211 | end_timestamp: Wed, 06 May 2020 19:33:09 UTC 212 | result: 213 | failed: false 214 | return_code: 0 215 | stderr: '' 216 | stdout: from the inside 217 | succeeded: true 218 | ``` 219 | 220 | ## Pack Configuration 221 | 222 | Pack configs will be in `/opt/stackstorm/configs/$PACKNAME`, which is a docker volume shared between st2api, st2actionrunner, and st2sensorcontainer. You can use the `st2 pack config ` in the st2client container in order to configure a pack. 223 | 224 | ### Use st2 pack config 225 | 226 | ```shell 227 | $ docker-compose exec st2client st2 pack config git 228 | repositories[0].url: https://github.com/StackStorm/st2-dockerfiles.git 229 | repositories[0].branch [master]: 230 | ~~~ Would you like to add another item to "repositories" array / list? [y]: n 231 | --- 232 | Do you want to preview the config in an editor before saving? [y]: n 233 | --- 234 | Do you want me to save it? [y]: y 235 | +----------+--------------------------------------------------------------+ 236 | | Property | Value | 237 | +----------+--------------------------------------------------------------+ 238 | | id | 5eb3164f566aa824ea88f536 | 239 | | pack | git | 240 | | values | { | 241 | | | "repositories": [ | 242 | | | { | 243 | | | "url": | 244 | | | "https://github.com/StackStorm/st2-dockerfiles.git", | 245 | | | "branch": "master" | 246 | | | } | 247 | | | ] | 248 | | | } | 249 | +----------+--------------------------------------------------------------+ 250 | ``` 251 | 252 | ### Copy a config file into a container 253 | 254 | First, find the actual container name of st2api by running `docker-compose ps st2api`. 255 | 256 | ```shell 257 | $ docker-compose ps st2api 258 | Name Command State Ports 259 | -------------------------------------------------------------------- 260 | compose_st2api_1 /opt/stackstorm/st2/bin/st ... Up 9101/tcp 261 | ``` 262 | 263 | Next, use `docker cp` to copy your file into place. 264 | 265 | ```shell 266 | docker cp git.yaml compose_st2api_1:/opt/stackstorm/configs/git.yaml 267 | ``` 268 | 269 | ## Register the pack config 270 | 271 | If you used `docker cp` to copy the config in, you will need to manually load that configuration. The st2client service does not need access to the configs directory, as it will talk to st2api. 272 | 273 | ```shell 274 | $ docker-compose exec st2client st2 run packs.load packs=git register=configs 275 | . 276 | id: 5eb3171c566aa824ea88f538 277 | action.ref: packs.load 278 | context.user: st2admin 279 | parameters: 280 | packs: 281 | - git 282 | register: configs 283 | status: succeeded 284 | start_timestamp: Wed, 06 May 2020 19:59:24 UTC 285 | end_timestamp: Wed, 06 May 2020 19:59:25 UTC 286 | result: 287 | exit_code: 0 288 | result: 289 | configs: 1 290 | stdout: '' 291 | ``` 292 | 293 | ## Local Pack Development 294 | 295 | See [Create and Contribute a Pack](https://docs.stackstorm.com/reference/packs.html) for how to actually develop a pack. 296 | 297 | If you are working on a development pack, you will need to register it and install the virutalenv (if it's python). 298 | 299 | ### packs.dev directory 300 | 301 | As mentioned above, your default `packs.dev` directory is relative to your `docker-compose.yml` file. However, if you start developing here, git will not like being inside another git directory. You will want to set `ST2_PACKS_DEV` to a directory outside of `st2-docker` and restart the docker-compose services. 302 | 303 | Example: We have a pack called helloworld in `packs.dev/helloworld`. The directory name has to match the pack name. So even if you have a git repo named "st2-helloworld", it should be cloned locally as "helloworld". 304 | 305 | For these examples, we will be operating inside the st2client container. 306 | 307 | ### Register the pack 308 | 309 | Register the pack by running `st2 run packs.load packs=, register=all`. Alternatively you can specify different register option (like register=actions) to focus on the parts you need to (re)register. You will be running this command a lot as you develop actions, sensors, rules and workflows. 310 | 311 | ```shell 312 | root@aaabd11745f0:/opt/stackstorm# st2 run packs.load packs=helloworld register=all 313 | . 314 | id: 5eb3100f71af8f57a458241f 315 | action.ref: packs.load 316 | context.user: st2admin 317 | parameters: 318 | packs: 319 | - helloworld 320 | register: all 321 | status: succeeded 322 | start_timestamp: Wed, 06 May 2020 19:29:19 UTC 323 | end_timestamp: Wed, 06 May 2020 19:29:21 UTC 324 | result: 325 | exit_code: 0 326 | result: 327 | actions: 13 328 | aliases: 0 329 | configs: 0 330 | policies: 0 331 | policy_types: 3 332 | rule_types: 2 333 | rules: 0 334 | runners: 15 335 | sensors: 0 336 | triggers: 0 337 | ``` 338 | 339 | ### Create the Python Virtual Environment 340 | 341 | If you are using python-runners in your locally developed pack, you will need to create the virtual environment by hand. You should typically only have to run this if you have changed your requirements.txt. 342 | 343 | To setup the virtual environment: `st2 run packs.setup_virtualenv packs=,` 344 | 345 | ```shell 346 | root@aaabd11745f0:/opt/stackstorm# st2 run packs.setup_virtualenv packs=helloworld 347 | .... 348 | id: 5eb311f871af8f57a4582433 349 | action.ref: packs.setup_virtualenv 350 | context.user: st2admin 351 | parameters: 352 | packs: 353 | - helloworld 354 | status: succeeded 355 | start_timestamp: Wed, 06 May 2020 19:37:28 UTC 356 | end_timestamp: Wed, 06 May 2020 19:37:36 UTC 357 | result: 358 | exit_code: 0 359 | result: 'Successfully set up virtualenv for the following packs: helloworld' 360 | stderr: 'st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Setting up virtualenv for pack "helloworld" (/opt/stackstorm/packs.dev/helloworld) 361 | st2.actions.python.SetupVirtualEnvironmentAction: INFO Virtualenv path "/opt/stackstorm/virtualenvs/helloworld" doesn''t exist 362 | st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Creating virtualenv for pack "helloworld" in "/opt/stackstorm/virtualenvs/helloworld" 363 | st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Creating virtualenv in "/opt/stackstorm/virtualenvs/helloworld" using Python binary "/opt/stackstorm/st2/bin/python" 364 | st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Running command "/opt/stackstorm/st2/bin/virtualenv -p /opt/stackstorm/st2/bin/python --always-copy --no-download /opt/stackstorm/virtualenvs/helloworld" to create virtualenv. 365 | st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Installing base requirements 366 | st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Installing requirement six>=1.9.0,<2.0 with command /opt/stackstorm/virtualenvs/helloworld/bin/pip install six>=1.9.0,<2.0. 367 | st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Installing pack specific requirements from "/opt/stackstorm/packs.dev/helloworld/requirements.txt" 368 | st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Installing requirements from file /opt/stackstorm/packs.dev/helloworld/requirements.txt with command /opt/stackstorm/virtualenvs/helloworld/bin/pip install -U -r /opt/stackstorm/packs.dev/helloworld/requirements.txt. 369 | st2.actions.python.SetupVirtualEnvironmentAction: DEBUG Virtualenv for pack "helloworld" successfully created in "/opt/stackstorm/virtualenvs/helloworld" 370 | ' 371 | stdout: '' 372 | ``` 373 | 374 | # Remove everything 375 | 376 | If you want to uninstall, or start from a "clean" installation, docker-compose can remove all the containers and volumes in one command. 377 | 378 | ```shell 379 | docker-compose down --remove-orphans -v 380 | ``` 381 | 382 | # Testing 383 | 384 | Testing st2-docker is now powered by [BATS](https://github.com/sstephenson/bats) Bash Automated Testing System. 385 | A "sidecar" like container loads the BATS libraries and binaries into a st2client-like container to run the tests 386 | 387 | To run the tests 388 | ```shell 389 | docker-compose -f tests/st2tests.yaml up 390 | ``` 391 | 392 | To do a clean teardown 393 | ```shell 394 | docker-compose -f tests/st2tests.yaml down -v 395 | ``` 396 | --------------------------------------------------------------------------------