From f0026b31347372c83d86b30942333a5fb743ab78 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Sat, 20 Apr 2024 15:29:49 +0200 Subject: [PATCH] docs: add all snippets for docker-compose deployments --- deployment/compose/README.md | 131 ++++++++++++++++++++++++++ deployment/compose/runner/base.yml | 13 +++ deployment/compose/runner/build.yml | 7 ++ deployment/compose/runner/config.yml | 6 ++ deployment/compose/server/base.yml | 20 ++++ deployment/compose/server/build.yml | 7 ++ deployment/compose/server/config.yml | 6 ++ deployment/compose/store/boltdb.yml | 12 +++ deployment/compose/store/local.yml | 31 ++++++ deployment/compose/store/mariadb.yml | 27 ++++++ deployment/compose/store/mysql.yml | 27 ++++++ deployment/compose/store/postgres.yml | 26 +++++ deployment/compose/store/sqlite.yml | 12 +++ 13 files changed, 325 insertions(+) create mode 100644 deployment/compose/README.md create mode 100644 deployment/compose/runner/base.yml create mode 100644 deployment/compose/runner/build.yml create mode 100644 deployment/compose/runner/config.yml create mode 100644 deployment/compose/server/base.yml create mode 100644 deployment/compose/server/build.yml create mode 100644 deployment/compose/server/config.yml create mode 100644 deployment/compose/store/boltdb.yml create mode 100644 deployment/compose/store/local.yml create mode 100644 deployment/compose/store/mariadb.yml create mode 100644 deployment/compose/store/mysql.yml create mode 100644 deployment/compose/store/postgres.yml create mode 100644 deployment/compose/store/sqlite.yml diff --git a/deployment/compose/README.md b/deployment/compose/README.md new file mode 100644 index 00000000..d5d2d1d0 --- /dev/null +++ b/deployment/compose/README.md @@ -0,0 +1,131 @@ +# Compose + +With the `docker-compose` snippets within this directory you are able to plug +different setups of Semaphore UI together. Below you can find some example +combinations. + +Some of the snippets define environment variables which could be optionally +overwritten if needed. + +## Server + +First of all we need the server definition and we need to decide if we want to +build the image dynamically or if we just want to use a released image. + +### Build + +This simply takes the currently cloned source and builds a new image including +all local changes. + +```console +docker-compose -f deployment/compose/server/base.yml -f deployment/compose/server/build.yml up +``` + +### Image + +This simply downloads the defined image from DockerHub and starts/configures it +properly based on the integrated bootstrapping scripts. + +```console +docker-compose -f deployment/compose/server/base.yml -f deployment/compose/server/image.yml up +``` + +### Config + +If you want to provide a custom `config.json` file to add options which are not +exposed as environment variables you could add this snippet which sources the +file from the current working directory. + +```console +docker-compose -f deployment/compose/server/config.yml up +``` + +## Runner + +If you want to try the remote runner functionality of Semaphore you could just +add this snippet to get a runner up and connected to semaphore. Similar to the +examples above for the server you got different options like building the runner +from the source or using our prebuilt images. + +### Build + +This simply takes the currently cloned source and builds a new image including +all local changes. + +```console +docker-compose -f deployment/compose/runner/base.yml -f deployment/compose/runner/build.yml up +``` + +### Image + +This simply downloads the defined image from DockerHub and starts/configures it +properly based on the integrated bootstrapping scripts. + +```console +docker-compose -f deployment/compose/runner/base.yml -f deployment/compose/runner/image.yml up +``` + +### Config + +If you want to provide a custom `config.json` file to add options which are not +exposed as environment variables you could add this snippet which sources the +file from the current working directory. + +```console +docker-compose -f deployment/compose/runner/config.yml up +``` + +## Database + +After deciding the base of it you should choose one of the supported databases. +Here we got currently the following options so far. + +### SQLite + +This simply configures a named volume for the SQLite storage used as a database +backend. + +```console +docker-compose -f deployment/compose/store/sqlite.yml up +``` + +### BoltDB + +This simply configures a named volume for the BoltDB storage used as a database +backend. + +```console +docker-compose -f deployment/compose/store/boltdb.yml up +``` + +### MariaDB + +This simply starts an additional container for a MariaDB instance used as a +database backend including the required credentials. + +```console +docker-compose -f deployment/compose/store/mariadb.yml up +``` + +### MySQL + +This simply starts an additional container for a MySQL instance used as a +database backend including the required credentials. + +```console +docker-compose -f deployment/compose/store/mysql.yml up +``` + +### PostgreSQL + +This simply starts an additional container for a PostgreSQL instance used as a +database backend including the required credentials. + +```console +docker-compose -f deployment/compose/store/postgres.yml up +``` + +## Cleanup + +After playing with the setup you are able to stop the whole setup by just +replacing `up` at the end of the command with `down`. diff --git a/deployment/compose/runner/base.yml b/deployment/compose/runner/base.yml new file mode 100644 index 00000000..3f0b79fe --- /dev/null +++ b/deployment/compose/runner/base.yml @@ -0,0 +1,13 @@ +version: "3.4" + +services: + runner: + image: docker.io/semaphoreui/runner:${SEMAPHORE_VERSION:-latest} + restart: always + environment: + SEMAPHORE_RUNNER_API_URL: ${SEMAPHORE_RUNNER_API_URL:-http://server:3000/api} + SEMAPHORE_RUNNER_REGISTRATION_TOKEN: ${SEMAPHORE_RUNNER_REGISTRATION_TOKEN:-H1wDyorbg6gTSwJlVwle2Fne} + + server: + environment: + SEMAPHORE_RUNNER_REGISTRATION_TOKEN: ${SEMAPHORE_RUNNER_REGISTRATION_TOKEN:-H1wDyorbg6gTSwJlVwle2Fne} diff --git a/deployment/compose/runner/build.yml b/deployment/compose/runner/build.yml new file mode 100644 index 00000000..0ff36ad2 --- /dev/null +++ b/deployment/compose/runner/build.yml @@ -0,0 +1,7 @@ +version: "3.4" + +services: + runner: + build: + context: ../../../ + dockerfile: deployment/docker/runner/Dockerfile diff --git a/deployment/compose/runner/config.yml b/deployment/compose/runner/config.yml new file mode 100644 index 00000000..95ac85bc --- /dev/null +++ b/deployment/compose/runner/config.yml @@ -0,0 +1,6 @@ +version: "3.4" + +services: + runner: + volumes: + - ${SEMAPHORE_RUNNER_LOCAL_CONFIG:-runner.json}:/etc/semaphore/config.json:Z diff --git a/deployment/compose/server/base.yml b/deployment/compose/server/base.yml new file mode 100644 index 00000000..ff8ba225 --- /dev/null +++ b/deployment/compose/server/base.yml @@ -0,0 +1,20 @@ +version: "3.4" + +volumes: + server: + +services: + server: + image: docker.io/semaphoreui/semaphore:${SEMAPHORE_VERSION:-latest} + restart: always + environment: + SEMAPHORE_ADMIN_NAME: ${SEMAPHORE_ADMIN_NAME:-Admin} + SEMAPHORE_ADMIN: ${SEMAPHORE_ADMIN_USERNAME:-admin} + SEMAPHORE_ADMIN_PASSWORD: ${SEMAPHORE_ADMIN_PASSWORD:-p455w0rd} + SEMAPHORE_ADMIN_EMAIL: ${SEMAPHORE_ADMIN_EMAIL:-admin@localhost} + SEMAPHORE_WEB_ROOT: ${SEMAPHORE_WEB_ROOT:-http://0.0.0.0:3000} + SEMAPHORE_ACCESS_KEY_ENCRYPTION: ${SEMAPHORE_ACCESS_KEY_ENCRYPTION:-IlRqgrrO5Gp27MlWakDX1xVrPv4jhoUx+ARY+qGyDxQ=} + volumes: + - server:/var/lib/semaphore + ports: + - "3000:3000" diff --git a/deployment/compose/server/build.yml b/deployment/compose/server/build.yml new file mode 100644 index 00000000..3824ed9d --- /dev/null +++ b/deployment/compose/server/build.yml @@ -0,0 +1,7 @@ +version: "3.4" + +services: + server: + build: + context: ../../../ + dockerfile: deployment/docker/runner/Dockerfile diff --git a/deployment/compose/server/config.yml b/deployment/compose/server/config.yml new file mode 100644 index 00000000..a9fce882 --- /dev/null +++ b/deployment/compose/server/config.yml @@ -0,0 +1,6 @@ +version: "3.4" + +services: + server: + volumes: + - ${SEMAPHORE_RUNNER_LOCAL_CONFIG:-config.json}:/etc/semaphore/config.json:Z diff --git a/deployment/compose/store/boltdb.yml b/deployment/compose/store/boltdb.yml new file mode 100644 index 00000000..9a56377e --- /dev/null +++ b/deployment/compose/store/boltdb.yml @@ -0,0 +1,12 @@ +version: "3.4" + +volumes: + boltdb: + +services: + server: + environment: + - SEMAPHORE_DB_DIALECT=bolt + - SEMAPHORE_DB_PATH=/var/lib/database + volumes: + - boltdb:/var/lib/database diff --git a/deployment/compose/store/local.yml b/deployment/compose/store/local.yml new file mode 100644 index 00000000..9ef10865 --- /dev/null +++ b/deployment/compose/store/local.yml @@ -0,0 +1,31 @@ +version: "3.4" + +volumes: + mariadb: + postgres: + +services: + mariadb: + image: mariadb:10.8 + restart: always + environment: + - MARIADB_ROOT_PASSWORD=root + - MARIADB_USER=semaphore + - MARIADB_PASSWORD=semaphore + - MARIADB_DATABASE=semaphore + volumes: + - mariadb:/var/lib/mysql + ports: + - 3306:3306 + + postgres: + image: postgres:14.3 + restart: always + environment: + - POSTGRES_USER=semaphore + - POSTGRES_PASSWORD=semaphore + - POSTGRES_DB=semaphore + volumes: + - postgres:/var/lib/postgresql + ports: + - 5432:5432 diff --git a/deployment/compose/store/mariadb.yml b/deployment/compose/store/mariadb.yml new file mode 100644 index 00000000..6a5a85c8 --- /dev/null +++ b/deployment/compose/store/mariadb.yml @@ -0,0 +1,27 @@ +version: "3.4" + +volumes: + mariadb: + +services: + server: + environment: + - SEMAPHORE_DB_DIALECT=mysql + - SEMAPHORE_DB_HOST=db + - SEMAPHORE_DB_PORT=3306 + - SEMAPHORE_DB_USER=${MARIADB_USERNAME:-semaphore} + - SEMAPHORE_DB_PASS=${MARIADB_PASSWORD:-semaphore} + - SEMAPHORE_DB=${MARIADB_DATABASE:-semaphore} + depends_on: + - db + + db: + image: mariadb:10.8 + restart: always + environment: + - MARIADB_ROOT_PASSWORD=${MARIADB_ROOT:-root} + - MARIADB_USER=${MARIADB_USERNAME:-semaphore} + - MARIADB_PASSWORD=${MARIADB_PASSWORD:-semaphore} + - MARIADB_DATABASE=${MARIADB_DATABASE:-semaphore} + volumes: + - mariadb:/var/lib/mysql diff --git a/deployment/compose/store/mysql.yml b/deployment/compose/store/mysql.yml new file mode 100644 index 00000000..6d12a4c8 --- /dev/null +++ b/deployment/compose/store/mysql.yml @@ -0,0 +1,27 @@ +version: "3.4" + +volumes: + mysql: + +services: + server: + environment: + - SEMAPHORE_DB_DIALECT=mysql + - SEMAPHORE_DB_HOST=db + - SEMAPHORE_DB_PORT=3306 + - SEMAPHORE_DB_USER=${MYSQL_USERNAME:-semaphore} + - SEMAPHORE_DB_PASS=${MYSQL_PASSWORD:-semaphore} + - SEMAPHORE_DB=${MYSQL_DATABASE:-semaphore} + depends_on: + - db + + db: + image: mysql:8.0 + restart: always + environment: + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT:-root} + - MYSQL_USER=${MYSQL_USERNAME:-semaphore} + - MYSQL_PASSWORD=${MYSQL_PASSWORD:-semaphore} + - MYSQL_DATABASE=${MYSQL_DATABASE:-semaphore} + volumes: + - mysql:/var/lib/mysql diff --git a/deployment/compose/store/postgres.yml b/deployment/compose/store/postgres.yml new file mode 100644 index 00000000..a791c329 --- /dev/null +++ b/deployment/compose/store/postgres.yml @@ -0,0 +1,26 @@ +version: "3.4" + +volumes: + postgres: + +services: + server: + environment: + - SEMAPHORE_DB_DIALECT=postgres + - SEMAPHORE_DB_HOST=db + - SEMAPHORE_DB_PORT=5432 + - SEMAPHORE_DB_USER=${POSTGRES_USERNAME:-semaphore} + - SEMAPHORE_DB_PASS=${POSTGRES_PASSWORD:-semaphore} + - SEMAPHORE_DB=${POSTGRES_DATABASE:-semaphore} + depends_on: + - db + + db: + image: postgres:14.3 + restart: always + environment: + - POSTGRES_USER=${POSTGRES_USERNAME:-semaphore} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-semaphore} + - POSTGRES_DB=${POSTGRES_DATABASE:-semaphore} + volumes: + - postgres:/var/lib/postgresql diff --git a/deployment/compose/store/sqlite.yml b/deployment/compose/store/sqlite.yml new file mode 100644 index 00000000..e069bedf --- /dev/null +++ b/deployment/compose/store/sqlite.yml @@ -0,0 +1,12 @@ +version: "3.4" + +volumes: + sqlite: + +services: + server: + environment: + - SEMAPHORE_DB_DIALECT=sqlite + - SEMAPHORE_DB_PATH=/var/lib/database + volumes: + - sqlite:/var/lib/database