Finishing make app refactor.

This commit is contained in:
2026-07-03 10:14:03 -07:00
parent 0f82b97ff6
commit 422d2a38d2
22 changed files with 187 additions and 160 deletions

View File

@@ -2,6 +2,8 @@ version: '3'
services:
lb:
image: docker.io/caddy:2.11.4-alpine
env_file:
- ./lb/lb.env
volumes:
# - /app/lb:/etc/caddy
- ./lb/:/etc/caddy

View File

@@ -0,0 +1,5 @@
IMAGE_DEPS := $(IMAGE_DEPS) \
app/dozzle/Caddyfile
app/dozzle/Caddyfile: $(apps_config) app/dozzle/make-caddyfile.sh
./app/dozzle/make-caddyfile.sh $(apps_config) > $@

View File

@@ -0,0 +1,15 @@
#/bin/bash
set -e
. $1 # source the apps.config file with then env vars
host_admin_password_encoded=`echo "$HOST_ADMIN_PASSWORD" | docker run --rm -i caddy:2 caddy hash-password`
echo '{$dozzle_SUBDOMAIN}.{$ROOT_DOMAIN} {'
echo " basic_auth {"
echo " $HOST_ADMIN_USER $host_admin_password_encoded"
echo " }"
echo " reverse_proxy http://dozzle:8080"
echo "}"
echo ""

View File

@@ -0,0 +1,4 @@
{$ghost_SUBDOMAIN}.{$ROOT_DOMAIN} {
import maintenance_intercept
reverse_proxy http://ghost:2368
}

View File

@@ -0,0 +1,5 @@
IMAGE_DEPS := $(IMAGE_DEPS) \
app/ghost/.compose-env
app/ghost/.compose-env: $(apps_config) app/ghost/.compose.env.tmpl app/ghost/make-ghost-env.sh
./app/ghost/make-ghost-env.sh $(apps_config)

View File

@@ -0,0 +1,32 @@
#!/bin/bash
set -e
. $1 # source the apps.config file with then env vars
read -r -a APP_CONFIGS <<< "$APP_CONFIGS"
ghost_subdomain=
for config_string in ${APP_CONFIGS[@]}; do
IFS=','
read -r -a config <<< "$config_string"
app=${config[0]}
subdomain=${config[1]}
if [ "$app" = "ghost" ]; then
ghost_subdomain="$subdomain"
fi
done
# write compose env file
echo "GHOST_DOMAIN=\"$ghost_subdomain.$ROOT_DOMAIN\"" > app/ghost/.compose-env
echo "GHOST_DATABASE_ROOT_PASSWORD=\"$GHOST_DATABASE_ROOT_PASSWORD\"" >> app/ghost/.compose-env
echo "GHOST_DATABASE_PASSWORD=\"$GHOST_DATABASE_PASSWORD\"" >> app/ghost/.compose-env
echo "mail__options__host=\"$SMTP_HOST\"" >> app/ghost/.compose-env
echo "mail__options__port=\"$SMTP_PORT\"" >> app/ghost/.compose-env
echo "mail__options__auth__user=\"$SMTP_AUTH_USER\"" >> app/ghost/.compose-env
echo "mail__options__auth__pass=\"$SMTP_AUTH_PASSWORD\"" >> app/ghost/.compose-env
echo "mail__from=\"$SMTP_FROM\"" >> app/ghost/.compose-env
cat app/ghost/.compose.env.tmpl >> app/ghost/.compose-env

View File

@@ -0,0 +1,3 @@
{$instance_control_SUBDOMAIN}.{$ROOT_DOMAIN} {
reverse_proxy http://instance_control:9000
}

View File

@@ -0,0 +1,8 @@
IMAGE_DEPS := $(IMAGE_DEPS) \
app/instance-control/webhook_secret \
app/instance-control/hooks/hooks.json
app/instance-control/webhook_secret: $(apps_config)
bash -c 'source $(apps_config); printf "%s\n" "$$INSTANCE_CONTROL_WEBHOOKS_SECRET" > $@'
app/instance-control/hooks/hooks.json: $(apps_config) app/instance-control/make-instance-control-config.sh
./app/instance-control/make-instance-control-config.sh $(apps_config)

View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -e
set -a # export everything in the config for later use by envsubst
. $1 # source the apps.config file with then env vars
# substitute template with env var to insert webhooks secret
envsubst < app/instance-control/hooks/hooks.json.tmpl > app/instance-control/hooks/hooks.json

View File

@@ -0,0 +1,26 @@
{$nassella_SUBDOMAIN}.{$ROOT_DOMAIN} {
import maintenance_intercept
route {
@authelia path /authelia /authelia/*
handle @authelia {
reverse_proxy nassella_authelia:9091
}
handle /unsecured/* {
reverse_proxy http://nassella:8080
}
forward_auth nassella_authelia:9091 {
uri /api/authz/forward-auth
copy_headers Remote-User Remote-Groups Remote-Email Remote-Name
}
reverse_proxy http://nassella:8080
}
}
lldap.{$nassella_SUBDOMAIN}.{$ROOT_DOMAIN} {
import maintenance_intercept
reverse_proxy nassella_lldap:17170
}

View File

@@ -0,0 +1,42 @@
IMAGE_DEPS := $(IMAGE_DEPS) \
app/nassella/postgres_db \
app/nassella/postgres_user \
app/nassella/postgres_password \
app/nassella/lldap_postgres_db \
app/nassella/lldap_postgres_user \
app/nassella/lldap_postgres_password \
app/nassella/authelia_postgres_db \
app/nassella/authelia_postgres_user \
app/nassella/authelia_postgres_password \
app/nassella/nassella.env \
app/nassella/authelia-config/configuration.yml \
app/nassella/lldap-config/lldap_config.toml
app/nassella/postgres_db: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_POSTGRES_DB" > $@'
app/nassella/postgres_user: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_POSTGRES_USER" > $@'
app/nassella/postgres_password: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_POSTGRES_PASSWORD" > $@'
app/nassella/authelia_postgres_db: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_AUTHELIA_POSTGRES_DB" > $@'
app/nassella/authelia_postgres_user: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_AUTHELIA_POSTGRES_USER" > $@'
app/nassella/authelia_postgres_password: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_AUTHELIA_POSTGRES_PASSWORD" > $@'
app/nassella/lldap_postgres_db: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_LLDAP_POSTGRES_DB" > $@'
app/nassella/lldap_postgres_user: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_LLDAP_POSTGRES_USER" > $@'
app/nassella/lldap_postgres_password: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_LLDAP_POSTGRES_PASSWORD" > $@'
app/nassella/lldap_admin_password: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_LLDAP_ADMIN_PASSWORD" > $@'
app/nassella/stripe_api_key: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NASSELLA_STRIPE_API_KEY" > $@'
app/nassella/authelia-config/configuration.yml: $(apps_config) app/nassella/authelia-config/configuration.yml.tmpl \
app/nassella/make-nassella-authelia-config.sh
./app/nassella/make-nassella-authelia-config.sh $(apps_config)
app/nassella/lldap-config/lldap_config.toml: $(apps_config) app/nassella/lldap-config/lldap_config.toml.tmpl \
app/nassella/make-nassella-lldap-config.sh
./app/nassella/make-nassella-lldap-config.sh $(apps_config)

View File

@@ -0,0 +1,39 @@
#!/bin/bash
set -e
set -a # export everything in the config for later use by envsubst
. $1 # source the apps.config file with then env vars
read -r -a APP_CONFIGS <<< "$APP_CONFIGS"
nassella_subdomain=
for config_string in ${APP_CONFIGS[@]}; do
IFS=','
read -r -a config <<< "$config_string"
app=${config[0]}
subdomain=${config[1]}
if [ "$app" = "nassella" ]; then
nassella_subdomain="$subdomain"
fi
done
export NASSELLA_FULL_DOMAIN="$nassella_subdomain.$ROOT_DOMAIN"
export NASSELLA_FULL_LLDAP_DOMAIN="$NASSELLA_LLDAP_SUBDOMAIN.$nassella_subdomain.$ROOT_DOMAIN"
envsubst < app/nassella/authelia-config/configuration.yml.tmpl > app/nassella/authelia-config/configuration.yml
# write secrets
echo "$NASSELLA_POSTGRES_DB" > app/nassella/postgres_db
echo "$NASSELLA_POSTGRES_USER" > app/nassella/postgres_user
echo "$NASSELLA_POSTGRES_PASSWORD" > app/nassella/postgres_password
echo "$NASSELLA_AUTHELIA_POSTGRES_DB" > app/nassella/authelia_postgres_db
echo "$NASSELLA_AUTHELIA_POSTGRES_USER" > app/nassella/authelia_postgres_user
echo "$NASSELLA_AUTHELIA_POSTGRES_PASSWORD" > app/nassella/authelia_postgres_password
echo "$NASSELLA_LLDAP_POSTGRES_DB" > app/nassella/lldap_postgres_db
echo "$NASSELLA_LLDAP_POSTGRES_USER" > app/nassella/lldap_postgres_user
echo "$NASSELLA_LLDAP_POSTGRES_PASSWORD" > app/nassella/lldap_postgres_password

View File

@@ -0,0 +1,39 @@
#!/bin/bash
set -e
set -a # export everything in the config for later use by envsubst
. $1 # source the apps.config file with then env vars
read -r -a APP_CONFIGS <<< "$APP_CONFIGS"
nassella_subdomain=
for config_string in ${APP_CONFIGS[@]}; do
IFS=','
read -r -a config <<< "$config_string"
app=${config[0]}
subdomain=${config[1]}
if [ "$app" = "nassella" ]; then
nassella_subdomain="$subdomain"
fi
done
export NASSELLA_FULL_DOMAIN="$nassella_subdomain.$ROOT_DOMAIN"
export NASSELLA_FULL_LLDAP_DOMAIN="$NASSELLA_LLDAP_SUBDOMAIN.$nassella_subdomain.$ROOT_DOMAIN"
envsubst < app/nassella/lldap-config/lldap_config.toml.tmpl > app/nassella/lldap-config/lldap_config.toml
# write secrets
echo "$NASSELLA_POSTGRES_DB" > app/nassella/postgres_db
echo "$NASSELLA_POSTGRES_USER" > app/nassella/postgres_user
echo "$NASSELLA_POSTGRES_PASSWORD" > app/nassella/postgres_password
echo "$NASSELLA_AUTHELIA_POSTGRES_DB" > app/nassella/authelia_postgres_db
echo "$NASSELLA_AUTHELIA_POSTGRES_USER" > app/nassella/authelia_postgres_user
echo "$NASSELLA_AUTHELIA_POSTGRES_PASSWORD" > app/nassella/authelia_postgres_password
echo "$NASSELLA_LLDAP_POSTGRES_DB" > app/nassella/lldap_postgres_db
echo "$NASSELLA_LLDAP_POSTGRES_USER" > app/nassella/lldap_postgres_user
echo "$NASSELLA_LLDAP_POSTGRES_PASSWORD" > app/nassella/lldap_postgres_password

View File

@@ -0,0 +1,4 @@
{$nextcloud_SUBDOMAIN}.{$ROOT_DOMAIN} {
import maintenance_intercept
reverse_proxy http://nextcloud:80
}

View File

@@ -0,0 +1,23 @@
IMAGE_DEPS := $(IMAGE_DEPS) \
app/nextcloud/nextcloud_admin_user \
app/nextcloud/nextcloud_admin_password \
app/nextcloud/postgres_db \
app/nextcloud/postgres_user \
app/nextcloud/postgres_password \
app/nextcloud/redis_password \
app/nextcloud/nextcloud.env
app/nextcloud/nextcloud_admin_user: $(apps_config)
bash -c 'source $(apps_config); printf "%s\n" "$$NEXTCLOUD_ADMIN_USER" > $@'
app/nextcloud/nextcloud_admin_password: $(apps_config)
bash -c 'source $(apps_config); printf "%s\n" "$$NEXTCLOUD_ADMIN_PASSWORD" > $@'
app/nextcloud/postgres_db: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NEXTCLOUD_POSTGRES_DB" > $@'
app/nextcloud/postgres_user: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NEXTCLOUD_POSTGRES_USER" > $@'
app/nextcloud/postgres_password: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NEXTCLOUD_POSTGRES_PASSWORD" > $@'
app/nextcloud/redis_password: $(apps_config)
bash -c 'source ./$(apps_config); printf "%s\n" "$$NEXTCLOUD_REDIS_PASSWORD" > $@'
app/nextcloud/nextcloud.env: $(apps_config) app/nextcloud/nextcloud.env.tmpl app/nextcloud/make-nextcloud-env.sh
./app/nextcloud/make-nextcloud-env.sh $(apps_config)

View File

@@ -0,0 +1,31 @@
#!/bin/bash
set -e
. $1 # source the apps.config file with then env vars
read -r -a APP_CONFIGS <<< "$APP_CONFIGS"
nextcloud_subdomain=
for config_string in ${APP_CONFIGS[@]}; do
IFS=','
read -r -a config <<< "$config_string"
app=${config[0]}
subdomain=${config[1]}
if [ "$app" = "nextcloud" ]; then
nextcloud_subdomain="$subdomain"
fi
done
# write container env file
echo "DOMAIN=\"$nextcloud_subdomain.$ROOT_DOMAIN\"" > app/nextcloud/nextcloud.env
cat app/nextcloud/nextcloud.env.tmpl >> app/nextcloud/nextcloud.env
# write secrets
echo "$NEXTCLOUD_POSTGRES_DB" > app/nextcloud/nextcloud_postgres_db
echo "$NEXTCLOUD_POSTGRES_USER" > app/nextcloud/nextcloud_postgres_user
echo "$NEXTCLOUD_POSTGRES_PASSWORD" > app/nextcloud/nextcloud_postgres_password
echo "$NEXTCLOUD_REDIS_PASSWORD" > app/nextcloud/nextcloud_redis_password

View File

@@ -0,0 +1,3 @@
{$wg_easy_SUBDOMAIN}.{$ROOT_DOMAIN} {
reverse_proxy http://wg-easy:80
}