Finishing make app refactor.
This commit is contained in:
115
Makefile
115
Makefile
@@ -3,8 +3,15 @@ TERRAFORM_ENV := production
|
||||
config_dir := ./config/
|
||||
apps_config := $(config_dir)apps.config
|
||||
|
||||
IMAGE_DEPS :=
|
||||
|
||||
COMPOSE_ENVS := $(shell if [ -d app/ ]; then find app/ -type f -name '.compose-env'; fi)
|
||||
|
||||
ALL_APPS_FILES = $(shell find all-apps/ -type f -name '*')
|
||||
|
||||
APP_MAKEFILES := $(shell if [ -d app/ ]; then find app/ -type f -name 'Makefile'; fi)
|
||||
-include $(APP_MAKEFILES)
|
||||
|
||||
# .dirstamp plus && $@ is like make magic to get this rule
|
||||
# to only run if the contents of all-apps changes
|
||||
app/.dirstamp: copy-apps.sh $(apps_config) $(ALL_APPS_FILES)
|
||||
@@ -18,67 +25,25 @@ app/.dirstamp: copy-apps.sh $(apps_config) $(ALL_APPS_FILES)
|
||||
|
||||
# # compose .env files
|
||||
# # (compose only supports one .env file at the root by default)
|
||||
app/.env: app/ghost/.compose-env
|
||||
app/.env: $(apps_config) $(COMPOSE_ENVS)
|
||||
find app/ -name ".compose-env" -exec cat > app/.env {} +
|
||||
|
||||
# Caddy / lb
|
||||
app/lb/Caddyfile: $(apps_config) make-caddyfile.sh
|
||||
app/lb/lb.env: $(apps_config) app/.dirstamp make-caddyfile.sh
|
||||
mkdir -p app/lb
|
||||
./make-caddyfile.sh $(apps_config) > app/lb/Caddyfile
|
||||
./make-caddyfile.sh $(apps_config) > $@
|
||||
|
||||
# Instance Control
|
||||
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) make-instance-control-config.sh
|
||||
./make-instance-control-config.sh $(apps_config)
|
||||
|
||||
# Nextcloud
|
||||
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 make-nextcloud-env.sh
|
||||
./make-nextcloud-env.sh $(apps_config)
|
||||
|
||||
# Nassella
|
||||
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 make-nassella-authelia-config.sh
|
||||
./make-nassella-authelia-config.sh $(apps_config)
|
||||
app/nassella/lldap-config/lldap_config.toml: $(apps_config) app/nassella/lldap-config/lldap_config.toml.tmpl make-nassella-lldap-config.sh
|
||||
./make-nassella-lldap-config.sh $(apps_config)
|
||||
|
||||
# Ghost
|
||||
app/ghost/.compose-env: $(apps_config) app/ghost/.compose.env.tmpl make-ghost-env.sh
|
||||
./make-ghost-env.sh $(apps_config)
|
||||
app/lb/Caddyfile: $(apps_config) app/.dirstamp
|
||||
echo "(maintenance_intercept) {" > app/lb/Caddyfile-tmp
|
||||
echo "@maintenanceModeActive file /maintenance/maintenance.on {" >> app/lb/Caddyfile-tmp
|
||||
echo " root /" >> app/lb/Caddyfile-tmp
|
||||
echo "}" >> app/lb/Caddyfile-tmp
|
||||
echo "handle @maintenanceModeActive {" >> app/lb/Caddyfile-tmp
|
||||
echo " respond \"We are performing a maintenance, come back later\" 503" >> app/lb/Caddyfile-tmp
|
||||
echo "}" >> app/lb/Caddyfile-tmp
|
||||
echo "}" >> app/lb/Caddyfile-tmp
|
||||
find app/ -name "Caddyfile" -exec cat >> app/lb/Caddyfile-tmp {} +
|
||||
mv app/lb/Caddyfile-tmp $@
|
||||
|
||||
# Backups / Restic / Backblaze
|
||||
restic-env: $(apps_config) make-restic-generated.sh
|
||||
@@ -87,29 +52,9 @@ restic-password: $(apps_config) make-restic-password.sh
|
||||
./make-restic-password.sh $(apps_config) > restic-password
|
||||
|
||||
ignition.json: cl.yaml app/.dirstamp \
|
||||
$(IMAGE_DEPS) \
|
||||
app/lb/lb.env \
|
||||
app/lb/Caddyfile \
|
||||
app/instance-control/webhook_secret \
|
||||
app/instance-control/hooks/hooks.json \
|
||||
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/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/ghost/.compose-env \
|
||||
restic-env \
|
||||
restic-password \
|
||||
restic-restore.sh \
|
||||
@@ -129,6 +74,12 @@ plan: ignition.json $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars
|
||||
announce-start:
|
||||
echo "NASSELLA_CONFIG: start"
|
||||
|
||||
# run this first to generate the all/ dir
|
||||
# then we can 'include' all the Makefiles in all/
|
||||
.PHONY: preapply
|
||||
preapply: app/.dirstamp
|
||||
echo "app generated"
|
||||
|
||||
apply: announce-start restic-init ignition.json $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars
|
||||
echo "NASSELLA_CONFIG: end"
|
||||
terraform init
|
||||
@@ -149,10 +100,12 @@ restic-snapshots: $(apps_config) restic-password
|
||||
|
||||
.PHONY: archive
|
||||
archive:
|
||||
echo "(" > all-apps/root-napp.scm
|
||||
find all-apps/ -name "napp.scm" -exec cat >> all-apps/root-napp.scm {} +
|
||||
echo ")" >> all-apps/root-napp.scm
|
||||
tar -cf nassella-latest.tar all-apps cl.yaml init-restic.sh main.tf make-caddyfile.sh Makefile \
|
||||
make-generated.sh make-nextcloud-env.sh make-ghost-env.sh make-restic-generated.sh make-restic-password.sh restic-snapshots.sh copy-apps.sh restic-restore.sh restic-snapshot.sh \
|
||||
make-nassella-authelia-config.sh make-nassella-lldap-config.sh .terraform.lock.hcl \
|
||||
make-instance-control-config.sh
|
||||
make-generated.sh make-restic-generated.sh make-restic-password.sh restic-snapshots.sh copy-apps.sh restic-restore.sh restic-snapshot.sh \
|
||||
.terraform.lock.hcl
|
||||
cp nassella-latest.tar src/
|
||||
|
||||
## to help me remember the command to run to test the config locally
|
||||
|
||||
Reference in New Issue
Block a user