|
|
|
TERRAFORM_ENV := production
|
|
|
|
|
|
|
|
config_dir := ./config/
|
|
|
|
apps_config := $(config_dir)apps.config
|
|
|
|
|
|
|
|
# .dirstamp plus && $@ is like make magic to get this rule
|
|
|
|
# to only run if the contents of all-apps changes
|
|
|
|
app/.dirstamp: all-apps/app.service all-apps/docker-compose.yaml \
|
|
|
|
$(wildcard all-apps/lb/*) \
|
|
|
|
$(wildcard all-apps/nextcloud/*) \
|
|
|
|
$(wildcard all-apps/wg-easy/*) \
|
|
|
|
$(wildcard all-apps/dozzle/*)
|
|
|
|
|
|
|
|
rm -Rf app/
|
|
|
|
cp -a all-apps app && touch $@
|
|
|
|
|
|
|
|
# Caddy / lb
|
|
|
|
all-apps/lb/Caddyfile: $(apps_config) make-caddyfile.sh
|
|
|
|
./make-caddyfile.sh $(apps_config) > all-apps/lb/Caddyfile
|
|
|
|
|
|
|
|
# Nextcloud
|
|
|
|
all-apps/nextcloud/nextcloud_admin_user: $(apps_config)
|
|
|
|
bash -c 'source $(apps_config); printf "%s\n" "$$NEXTCLOUD_ADMIN_USER" > $@'
|
|
|
|
all-apps/nextcloud/nextcloud_admin_password: $(apps_config)
|
|
|
|
bash -c 'source $(apps_config); printf "%s\n" "$$NEXTCLOUD_ADMIN_PASSWORD" > $@'
|
|
|
|
all-apps/nextcloud/postgres_db: $(apps_config)
|
|
|
|
bash -c 'source ./$(apps_config); printf "%s\n" "$$NEXTCLOUD_POSTGRES_DB" > $@'
|
|
|
|
all-apps/nextcloud/postgres_user: $(apps_config)
|
|
|
|
bash -c 'source ./$(apps_config); printf "%s\n" "$$NEXTCLOUD_POSTGRES_USER" > $@'
|
|
|
|
all-apps/nextcloud/postgres_password: $(apps_config)
|
|
|
|
bash -c 'source ./$(apps_config); printf "%s\n" "$$NEXTCLOUD_POSTGRES_PASSWORD" > $@'
|
|
|
|
all-apps/nextcloud/redis_password: $(apps_config)
|
|
|
|
bash -c 'source ./$(apps_config); printf "%s\n" "$$NEXTCLOUD_REDIS_PASSWORD" > $@'
|
|
|
|
all-apps/nextcloud/nextcloud.env: $(apps_config) make-nextcloud-env.sh
|
|
|
|
./make-nextcloud-env.sh $(apps_config)
|
|
|
|
|
|
|
|
ignition.json: cl.yaml app/.dirstamp \
|
|
|
|
all-apps/lb/Caddyfile \
|
|
|
|
all-apps/nextcloud/nextcloud_admin_user \
|
|
|
|
all-apps/nextcloud/nextcloud_admin_password \
|
|
|
|
all-apps/nextcloud/postgres_db \
|
|
|
|
all-apps/nextcloud/postgres_user \
|
|
|
|
all-apps/nextcloud/postgres_password \
|
|
|
|
all-apps/nextcloud/redis_password \
|
|
|
|
all-apps/nextcloud/nextcloud.env
|
|
|
|
cat cl.yaml | docker run --rm --volume /home/tjhintz/.ssh/id_rsa.pub:/pwd/ssh-keys --volume ${PWD}:/pwd --workdir /pwd -i quay.io/coreos/butane:latest -d /pwd > ignition.json
|
|
|
|
|
|
|
|
generated.tfvars: $(apps_config) make-generated.sh
|
|
|
|
./make-generated.sh $(apps_config) > generated.tfvars
|
|
|
|
|
|
|
|
plan: ignition.json $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars
|
|
|
|
bash -c "terraform plan -var-file=<(cat $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars)"
|
|
|
|
|
|
|
|
apply: ignition.json $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars
|
|
|
|
bash -c "terraform apply -var-file=<(cat $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars)"
|
|
|
|
|
|
|
|
destroy: ignition.json $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars
|
|
|
|
bash -c "terraform destroy -var-file=<(cat $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars)"
|
|
|
|
|
|
|
|
## to help me remember the command to run to test the config locally
|
|
|
|
testlocalhost:
|
|
|
|
curl -k --resolve localhost:443:146.190.12.129 https://localhost
|
|
|
|
|
|
|
|
flatcarbuild: ignition.json
|
|
|
|
cp --reflink=auto flatcar/flatcar_production_qemu_image.img.fresh flatcar/flatcar_production_qemu_image.img
|
|
|
|
|
|
|
|
flatcarrun:
|
|
|
|
./flatcar/flatcar_production_qemu.sh -i ignition.json
|
|
|
|
|