sovereign-stack/deployment/www/stub/nginx_yml.sh

136 lines
3.2 KiB
Bash
Raw Normal View History

2022-09-28 17:59:01 +00:00
#!/bin/bash
2022-10-29 15:34:17 +00:00
set -eu
2022-09-28 17:59:01 +00:00
cd "$(dirname "$0")"
#https://github.com/fiatjaf/expensive-relay
# NOSTR RELAY WHICH REQUIRES PAYMENTS.
DOCKER_YAML_PATH="$PROJECT_PATH/nginx.yml"
cat > "$DOCKER_YAML_PATH" <<EOL
version: "3.8"
services:
nginx:
image: ${NGINX_IMAGE}
ports:
- 0.0.0.0:443:443
- 0.0.0.0:80:80
networks:
EOL
for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
export DOMAIN_NAME="$DOMAIN_NAME"
export SITE_PATH="$SITES_PATH/$DOMAIN_NAME"
# source the site path so we know what features it has.
source ../../../reset_env.sh
source "$SITE_PATH/site_definition"
source ../../../domain_env.sh
2022-10-08 16:44:46 +00:00
for LANGUAGE_CODE in ${SITE_LANGUAGE_CODES//,/ }; do
# We create another ghost instance under /
2022-09-28 17:59:01 +00:00
cat >> "$DOCKER_YAML_PATH" <<EOL
2022-10-19 17:15:38 +00:00
- ghostnet-$DOMAIN_IDENTIFIER-$LANGUAGE_CODE
2022-09-28 17:59:01 +00:00
EOL
2022-10-08 16:44:46 +00:00
if [ "$LANGUAGE_CODE" = en ]; then
if [ "$DEPLOY_GITEA" = "true" ]; then
2022-10-22 00:04:03 +00:00
cat >> "$DOCKER_YAML_PATH" <<EOL
2022-10-19 17:15:38 +00:00
- giteanet-$DOMAIN_IDENTIFIER-en
2022-10-08 16:44:46 +00:00
EOL
fi
2022-10-22 00:04:03 +00:00
if [ "$DEPLOY_NEXTCLOUD" = "true" ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
- nextcloudnet-$DOMAIN_IDENTIFIER-en
EOL
2022-11-14 01:23:48 +00:00
fi
2022-10-22 00:04:03 +00:00
2022-11-14 01:23:48 +00:00
if [ "$DEPLOY_NOSTR_RELAY" = "true" ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
- nostrnet-$DOMAIN_IDENTIFIER
EOL
2022-10-22 00:04:03 +00:00
fi
2022-10-08 16:44:46 +00:00
fi
2022-09-28 17:59:01 +00:00
done
2022-10-08 16:44:46 +00:00
2022-09-28 17:59:01 +00:00
done
cat >> "$DOCKER_YAML_PATH" <<EOL
volumes:
- ${REMOTE_HOME}/letsencrypt:/etc/letsencrypt:ro
configs:
- source: nginx-config
target: /etc/nginx/nginx.conf
deploy:
restart_policy:
condition: on-failure
configs:
nginx-config:
file: ${PROJECT_PATH}/nginx.conf
EOL
################ NETWORKS SECTION
cat >> "$DOCKER_YAML_PATH" <<EOL
networks:
EOL
for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
export DOMAIN_NAME="$DOMAIN_NAME"
export SITE_PATH="$SITES_PATH/$DOMAIN_NAME"
# source the site path so we know what features it has.
source ../../../reset_env.sh
source "$SITE_PATH/site_definition"
source ../../../domain_env.sh
# for each language specified in the site_definition, we spawn a separate ghost container
# at https://www.domain.com/$LANGUAGE_CODE
for LANGUAGE_CODE in ${SITE_LANGUAGE_CODES//,/ }; do
cat >> "$DOCKER_YAML_PATH" <<EOL
2022-10-19 17:15:38 +00:00
ghostnet-$DOMAIN_IDENTIFIER-$LANGUAGE_CODE:
2022-09-28 17:59:01 +00:00
attachable: true
EOL
done
if [ "$DEPLOY_GITEA" = true ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
2022-10-19 17:15:38 +00:00
giteanet-$DOMAIN_IDENTIFIER-en:
attachable: true
2022-10-22 00:04:03 +00:00
EOL
fi
if [ "$DEPLOY_NEXTCLOUD" = "true" ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
nextcloudnet-$DOMAIN_IDENTIFIER-en:
attachable: true
2022-11-14 01:23:48 +00:00
EOL
fi
if [ "$DEPLOY_NOSTR_RELAY" = "true" ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
nostrnet-$DOMAIN_IDENTIFIER:
attachable: true
EOL
fi
2022-09-28 17:59:01 +00:00
done
docker stack deploy -c "$DOCKER_YAML_PATH" "reverse-proxy"
# iterate over all our domains and create the nginx config file.