From 3469570eb258a13bc0a837cd5e842e915a8c7fb6 Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 20 Feb 2024 10:09:30 +0000 Subject: [PATCH] feature: Add Sablier --- commands/env.cmd | 13 ++++ commands/svc.cmd | 15 +++++ config/sablier/sablier.yml | 20 ++++++ config/sablier/theme/warden.html | 65 +++++++++++++++++++ config/traefik/traefik.yml | 5 ++ docker/docker-compose.sablier.yml | 13 ++++ environments/includes/allure.base.yml | 2 + environments/includes/db.base.yml | 3 + environments/includes/elastichq.base.yml | 2 + environments/includes/elasticsearch.base.yml | 2 + environments/includes/opensearch.base.yml | 2 + environments/includes/php-fpm.base.yml | 6 ++ environments/includes/rabbitmq.base.yml | 2 + environments/includes/redis.base.yml | 3 + .../includes/sablier-varnish.base.yml | 16 +++++ environments/includes/sablier.base.yml | 15 +++++ 16 files changed, 184 insertions(+) create mode 100644 config/sablier/sablier.yml create mode 100644 config/sablier/theme/warden.html create mode 100644 docker/docker-compose.sablier.yml create mode 100644 environments/includes/sablier-varnish.base.yml create mode 100644 environments/includes/sablier.base.yml diff --git a/commands/env.cmd b/commands/env.cmd index 849de405..8381381d 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -72,6 +72,12 @@ if [[ ${WARDEN_ENV_SUBT} == "linux" && $UID == 1000 ]]; then export SSH_AUTH_SOCK_PATH_ENV=/run/host-services/ssh-auth.sock fi +# Default Sablier Theme +if [[ -z $TRAEFIK_SABLIER_THEME ]]; then + TRAEFIK_SABLIER_THEME=${WARDEN_SABLIER_DEFAULT_THEME:-warden} +fi +export TRAEFIK_SABLIER_THEME + ## configure docker compose files DOCKER_COMPOSE_ARGS=() @@ -130,6 +136,13 @@ fi [[ ${WARDEN_MAGEPACK} -eq 1 ]] \ && appendEnvPartialIfExists "${WARDEN_ENV_TYPE}.magepack" +if [[ ${WARDEN_SABLIER_ENABLE:-0} -eq 1 ]]; then + appendEnvPartialIfExists "sablier" + + [[ ${WARDEN_VARNISH} -eq 1 ]] \ + && appendEnvPartialIfExists "sablier-varnish" +fi + if [[ -f "${WARDEN_ENV_PATH}/.warden/warden-env.yml" ]]; then DOCKER_COMPOSE_ARGS+=("-f") DOCKER_COMPOSE_ARGS+=("${WARDEN_ENV_PATH}/.warden/warden-env.yml") diff --git a/commands/svc.cmd b/commands/svc.cmd index 1b94d494..bd3155fb 100644 --- a/commands/svc.cmd +++ b/commands/svc.cmd @@ -23,6 +23,8 @@ if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then eval "$(grep "^WARDEN_DNSMASQ_ENABLE" "${WARDEN_HOME_DIR}/.env")" # Check Portainer eval "$(grep "^WARDEN_PORTAINER_ENABLE" "${WARDEN_HOME_DIR}/.env")" + # Check Sablier + eval "$(grep "^WARDEN_SABLIER_ENABLE" "${WARDEN_HOME_DIR}/.env")" fi DOCKER_COMPOSE_ARGS+=("-f") @@ -41,6 +43,12 @@ if [[ "${WARDEN_PORTAINER_ENABLE}" == 1 ]]; then DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.portainer.yml") fi +WARDEN_SABLIER_ENABLE="${WARDEN_SABLIER_ENABLE:-0}" +if [[ "$WARDEN_SABLIER_ENABLE" == "1" ]]; then + DOCKER_COMPOSE_ARGS+=("-f") + DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.sablier.yml") +fi + ## allow an additional docker-compose file to be loaded for global services if [[ -f "${WARDEN_HOME_DIR}/docker-compose.yml" ]]; then DOCKER_COMPOSE_ARGS+=("-f") @@ -64,6 +72,13 @@ if [[ "${WARDEN_PARAMS[0]}" == "up" ]]; then mkdir -p "${WARDEN_HOME_DIR}/etc/traefik" cp "${WARDEN_DIR}/config/traefik/traefik.yml" "${WARDEN_HOME_DIR}/etc/traefik/traefik.yml" + ## copy sablier configuration files into location where they'll be mounted into containers from + if [[ "$WARDEN_SABLIER_ENABLE" == "1" ]]; then + mkdir -p "${WARDEN_HOME_DIR}/etc/sablier/theme" + cp "${WARDEN_DIR}/config/sablier/sablier.yml" "${WARDEN_HOME_DIR}/etc/sablier/sablier.yml" + cp "${WARDEN_DIR}/config/sablier/theme/warden.html" "${WARDEN_HOME_DIR}/etc/sablier/theme/warden.html" + fi + ## generate dynamic traefik ssl termination configuration cat > "${WARDEN_HOME_DIR}/etc/traefik/dynamic.yml" <<-EOT tls: diff --git a/config/sablier/sablier.yml b/config/sablier/sablier.yml new file mode 100644 index 00000000..49c82515 --- /dev/null +++ b/config/sablier/sablier.yml @@ -0,0 +1,20 @@ +provider: + name: docker +server: + port: 10000 + base-path: / +storage: + file: +sessions: + default-duration: 5m + expiration-interval: 20s +logging: + level: info +strategy: + dynamic: + custom-themes-path: + show-details-by-default: true + default-theme: warden + default-refresh-frequency: 5s + blocking: + default-timeout: 1m \ No newline at end of file diff --git a/config/sablier/theme/warden.html b/config/sablier/theme/warden.html new file mode 100644 index 00000000..5cb47ecc --- /dev/null +++ b/config/sablier/theme/warden.html @@ -0,0 +1,65 @@ + + + + Warden + + + + + + + + +
+
+ +
 _       __               __         
+| |     / /___ __________/ /__  ____ 
+| | /| / / __ `/ ___/ __  / _ \/ __ \
+| |/ |/ / /_/ / /  / /_/ /  __/ / / /
+|__/|__/\__,_/_/   \__,_/\___/_/ /_/ 
+            
+

Starting {{ .DisplayName }}

+

Your instance(s) will stop after {{ .SessionDuration }} of inactivity

+
+ + {{- range $i, $instance := .InstanceStates }} + + + {{- if $instance.Error }} + + {{- else }} + + {{- end}} + + {{ end -}} +
{{ $instance.Name }}{{ $instance.Error }}{{ $instance.Status }} ({{ $instance.CurrentReplicas }}/{{ $instance.DesiredReplicas }})
+
+
+
+ + diff --git a/config/traefik/traefik.yml b/config/traefik/traefik.yml index 4f8f8593..67403439 100644 --- a/config/traefik/traefik.yml +++ b/config/traefik/traefik.yml @@ -23,3 +23,8 @@ log: global: checkNewVersion: false sendAnonymousUsage: false +experimental: + plugins: + sablier: + moduleName: github.com/acouvreur/sablier + version: v1.5.0 diff --git a/docker/docker-compose.sablier.yml b/docker/docker-compose.sablier.yml new file mode 100644 index 00000000..d623f51e --- /dev/null +++ b/docker/docker-compose.sablier.yml @@ -0,0 +1,13 @@ +version: "3.5" +services: + sablier: + container_name: sablier + image: acouvreur/sablier:${SABLIER_VERSION:-latest} + restart: ${WARDEN_RESTART_POLICY:-always} + command: + - start + - --provider.name=docker + volumes: + - '/var/run/docker.sock:/var/run/docker.sock' + - ${WARDEN_HOME_DIR}/etc/sablier/sablier.yml:/etc/sablier/sablier.yml + - ${WARDEN_HOME_DIR}/etc/sablier/theme:/etc/sablier/themes \ No newline at end of file diff --git a/environments/includes/allure.base.yml b/environments/includes/allure.base.yml index 97248848..cc7ab5c4 100644 --- a/environments/includes/allure.base.yml +++ b/environments/includes/allure.base.yml @@ -12,6 +12,8 @@ services: # - traefik.http.routers.${WARDEN_ENV_NAME}-allure-api.tls=true # - traefik.http.routers.${WARDEN_ENV_NAME}-allure-api.rule=Host(`allure-api.${TRAEFIK_DOMAIN}`) # - traefik.http.services.${WARDEN_ENV_NAME}-allure-api.loadbalancer.server.port=5050 + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} volumes: - allure-results:/app/allure-results environment: diff --git a/environments/includes/db.base.yml b/environments/includes/db.base.yml index 97c26d80..a4f29835 100644 --- a/environments/includes/db.base.yml +++ b/environments/includes/db.base.yml @@ -15,6 +15,9 @@ services: volumes: - dbdata:/var/lib/mysql - sqlhistory:/sql_history + labels: + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} volumes: dbdata: diff --git a/environments/includes/elastichq.base.yml b/environments/includes/elastichq.base.yml index 8b1f907b..1a0c5ed7 100644 --- a/environments/includes/elastichq.base.yml +++ b/environments/includes/elastichq.base.yml @@ -8,6 +8,8 @@ services: - traefik.http.routers.${WARDEN_ENV_NAME}-elasticsearch-hq.rule=Host(`elastichq.${TRAEFIK_DOMAIN}`) - traefik.http.services.${WARDEN_ENV_NAME}-elasticsearch-hq.loadbalancer.server.port=5000 - traefik.docker.network=${WARDEN_ENV_NAME}_default + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} environment: - HQ_DEFAULT_URL=http://elasticsearch:9200 diff --git a/environments/includes/elasticsearch.base.yml b/environments/includes/elasticsearch.base.yml index 82caabf9..4574b95f 100644 --- a/environments/includes/elasticsearch.base.yml +++ b/environments/includes/elasticsearch.base.yml @@ -8,6 +8,8 @@ services: - traefik.http.routers.${WARDEN_ENV_NAME}-elasticsearch.rule=Host(`elasticsearch.${TRAEFIK_DOMAIN}`) - traefik.http.services.${WARDEN_ENV_NAME}-elasticsearch.loadbalancer.server.port=9200 - traefik.docker.network=${WARDEN_ENV_NAME}_default + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} environment: - discovery.type=single-node - xpack.security.enabled=false diff --git a/environments/includes/opensearch.base.yml b/environments/includes/opensearch.base.yml index f6cdeb6d..489de1ca 100644 --- a/environments/includes/opensearch.base.yml +++ b/environments/includes/opensearch.base.yml @@ -8,6 +8,8 @@ services: - traefik.http.routers.${WARDEN_ENV_NAME}-opensearch.rule=Host(`opensearch.${TRAEFIK_DOMAIN}`) - traefik.http.services.${WARDEN_ENV_NAME}-opensearch.loadbalancer.server.port=9200 - traefik.docker.network=${WARDEN_ENV_NAME}_default + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} environment: - DISABLE_SECURITY_PLUGIN=true - discovery.type=single-node diff --git a/environments/includes/php-fpm.base.yml b/environments/includes/php-fpm.base.yml index 8cde6821..d6d99672 100644 --- a/environments/includes/php-fpm.base.yml +++ b/environments/includes/php-fpm.base.yml @@ -29,6 +29,9 @@ services: - CHOWN_DIR_LIST=${CHOWN_DIR_LIST:-} volumes: *volumes extra_hosts: *extra_hosts + labels: + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} php-debug: hostname: "${WARDEN_ENV_NAME}-php-debug" @@ -47,6 +50,9 @@ services: extra_hosts: *extra_hosts depends_on: - php-fpm + labels: + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} volumes: bashhistory: sshdirectory: diff --git a/environments/includes/rabbitmq.base.yml b/environments/includes/rabbitmq.base.yml index dfcf1caa..9bafd816 100644 --- a/environments/includes/rabbitmq.base.yml +++ b/environments/includes/rabbitmq.base.yml @@ -8,6 +8,8 @@ services: - traefik.http.routers.${WARDEN_ENV_NAME}-rabbitmq.rule=Host(`rabbitmq.${TRAEFIK_DOMAIN}`) - traefik.http.services.${WARDEN_ENV_NAME}-rabbitmq.loadbalancer.server.port=15672 - traefik.docker.network=${WARDEN_ENV_NAME}_default + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} volumes: - rabbitmq:/var/lib/rabbitmq diff --git a/environments/includes/redis.base.yml b/environments/includes/redis.base.yml index 2067bb33..2c27f637 100644 --- a/environments/includes/redis.base.yml +++ b/environments/includes/redis.base.yml @@ -4,6 +4,9 @@ services: image: ${WARDEN_IMAGE_REPOSITORY}/redis:${REDIS_VERSION:-5.0} volumes: - redis:/data + labels: + - sablier.enable=true + - sablier.group=${WARDEN_ENV_NAME} volumes: redis: diff --git a/environments/includes/sablier-varnish.base.yml b/environments/includes/sablier-varnish.base.yml new file mode 100644 index 00000000..6009477b --- /dev/null +++ b/environments/includes/sablier-varnish.base.yml @@ -0,0 +1,16 @@ +version: "3.5" +services: + nginx: + labels: + - traefik.enable=false + + varnish: + labels: + - traefik.enable=true + - traefik.http.routers.${WARDEN_ENV_NAME}-varnish.middlewares=sablier-${WARDEN_ENV_NAME}@docker + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.sablierUrl=http://sablier:10000 + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.sessionDuration=${TRAEFIK_SABLIER_DURATION:-30m} + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.group=${WARDEN_ENV_NAME} + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.dynamic.name=${WARDEN_ENV_NAME} + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.dynamic.displayName=${WARDEN_ENV_NAME} + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.dynamic.theme=${TRAEFIK_SABLIER_THEME} \ No newline at end of file diff --git a/environments/includes/sablier.base.yml b/environments/includes/sablier.base.yml new file mode 100644 index 00000000..ef160124 --- /dev/null +++ b/environments/includes/sablier.base.yml @@ -0,0 +1,15 @@ +version: "3.5" +services: + nginx: + networks: + - default + labels: + - traefik.enable=true + - sablier.enable=false + - traefik.http.routers.${WARDEN_ENV_NAME}-nginx.middlewares=sablier-${WARDEN_ENV_NAME}@docker + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.sablierUrl=http://sablier:10000 + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.sessionDuration=${TRAEFIK_SABLIER_DURATION:-30m} + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.group=${WARDEN_ENV_NAME} + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.dynamic.name=${WARDEN_ENV_NAME} + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.dynamic.displayName=${WARDEN_ENV_NAME} + - traefik.http.middlewares.sablier-${WARDEN_ENV_NAME}.plugin.sablier.dynamic.theme=${TRAEFIK_SABLIER_THEME} \ No newline at end of file