Skip to content

Commit

Permalink
feature: Add Sablier
Browse files Browse the repository at this point in the history
  • Loading branch information
SamJUK committed Oct 20, 2024
1 parent 086cdb7 commit 3469570
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 0 deletions.
13 changes: 13 additions & 0 deletions commands/env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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=()

Expand Down Expand Up @@ -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")
Expand Down
15 changes: 15 additions & 0 deletions commands/svc.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions config/sablier/sablier.yml
Original file line number Diff line number Diff line change
@@ -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
65 changes: 65 additions & 0 deletions config/sablier/theme/warden.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<html lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<title>Warden</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="refresh" content="{{ .RefreshFrequency }}">
<link rel="preconnect" href="https://fonts.bunny.net" crossorigin="">
<link rel="dns-prefetch" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css2?family=Open+Sans:wght@400;700&amp;display=swap" rel="stylesheet">
<style>
html,body {background-color:black;color:#fff;font-family:'Open Sans',sans-serif;height:100vh;margin:0;font-size:0}
.container {height:100vh;align-items:center;display:flex;justify-content:center;position:relative}
.wrap {text-align:center}
.ghost {animation:float 3s ease-out infinite}
@keyframes float { 50% {transform:translate(0,20px)}}
.shadowFrame {width:130px;margin: 10px auto 0 auto}
.shadow {animation:shrink 3s ease-out infinite;transform-origin:center center}
@keyframes shrink {0%{width:90%;margin:0 5%} 50% {width:60%;margin:0 18%} 100% {width:90%;margin:0 5%}}
h3 {font-size:17px;text-transform: uppercase;margin:0.3em auto}
.description {font-size:13px;color:#feb8c5}
.details {color:#999;width:100%}
.details table {width:100%}
.details td {white-space:nowrap;font-size:11px}
.details .name {text-align:right;padding-right:.6em;width:50%}
.details .value {text-align:left;padding-left:.6em;font-family:'Lucida Console','Courier New',monospace}
.details .value.error {color: rgb(231, 89, 82)}
.details .value.success {color: rgb(82, 231, 142)}
</style>
</head>
<body>
<div class="container">
<div class="wrap">

<pre class="warden-mark" style="
color: green;
font-size: 22px;
line-height: 1em;
font-weight: 600;
text-shadow: 2px 2px 3px #005003;
"> _ __ __
| | / /___ __________/ /__ ____
| | /| / / __ `/ ___/ __ / _ \/ __ \
| |/ |/ / /_/ / / / /_/ / __/ / / /
|__/|__/\__,_/_/ \__,_/\___/_/ /_/
</pre>
<h3><span>Starting</span> {{ .DisplayName }}</h3>
<p class="description">Your instance(s) will stop after {{ .SessionDuration }} of inactivity</p>
<div class="details">
<table>
{{- range $i, $instance := .InstanceStates }}
<tr>
<td class="name">{{ $instance.Name }}</td>
{{- if $instance.Error }}
<td class="value error">{{ $instance.Error }}</td>
{{- else }}
<td class="value success">{{ $instance.Status }} ({{ $instance.CurrentReplicas }}/{{ $instance.DesiredReplicas }})</td>
{{- end}}
</tr>
{{ end -}}
</table>
</div>
</div>
</div>

</body></html>
5 changes: 5 additions & 0 deletions config/traefik/traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ log:
global:
checkNewVersion: false
sendAnonymousUsage: false
experimental:
plugins:
sablier:
moduleName: github.com/acouvreur/sablier
version: v1.5.0
13 changes: 13 additions & 0 deletions docker/docker-compose.sablier.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions environments/includes/allure.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions environments/includes/db.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ services:
volumes:
- dbdata:/var/lib/mysql
- sqlhistory:/sql_history
labels:
- sablier.enable=true
- sablier.group=${WARDEN_ENV_NAME}

volumes:
dbdata:
Expand Down
2 changes: 2 additions & 0 deletions environments/includes/elastichq.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions environments/includes/elasticsearch.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions environments/includes/opensearch.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions environments/includes/php-fpm.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
2 changes: 2 additions & 0 deletions environments/includes/rabbitmq.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions environments/includes/redis.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
16 changes: 16 additions & 0 deletions environments/includes/sablier-varnish.base.yml
Original file line number Diff line number Diff line change
@@ -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}
15 changes: 15 additions & 0 deletions environments/includes/sablier.base.yml
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 3469570

Please sign in to comment.