project/www/stub/nginx_yml.sh

148 lines
3.5 KiB
Bash
Raw Normal View History

2023-03-06 19:30:56 +00:00
#!/bin/bash
2023-03-06 19:56:45 +00:00
set -e
2023-03-06 19:30:56 +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
2023-04-04 15:08:22 +00:00
for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
export DOMAIN_NAME="$DOMAIN_NAME"
export SITE_PATH="$SITES_PATH/$DOMAIN_NAME"
2023-03-06 19:30:56 +00:00
2023-04-04 15:08:22 +00:00
# source the site path so we know what features it has.
source ../../../../defaults.sh
source "$SITE_PATH/site.conf"
source ../../domain_env.sh
2023-03-06 19:30:56 +00:00
2023-04-04 15:08:22 +00:00
for LANGUAGE_CODE in ${SITE_LANGUAGE_CODES//,/ }; do
# We create another ghost instance under /
if [ "$DEPLOY_GHOST" = true ]; then
2023-03-06 19:30:56 +00:00
cat >> "$DOCKER_YAML_PATH" <<EOL
- ghostnet-$DOMAIN_IDENTIFIER-$LANGUAGE_CODE
EOL
2023-04-04 15:08:22 +00:00
fi
if [ "$LANGUAGE_CODE" = en ]; then
if [ "$DEPLOY_GITEA" = "true" ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
- giteanet-$DOMAIN_IDENTIFIER-en
EOL
2023-04-04 15:08:22 +00:00
fi
2023-03-06 19:30:56 +00:00
2023-04-04 15:08:22 +00:00
if [ "$DEPLOY_NEXTCLOUD" = "true" ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
- nextcloudnet-$DOMAIN_IDENTIFIER-en
EOL
2023-04-04 15:08:22 +00:00
fi
2023-03-06 19:30:56 +00:00
2023-04-04 14:56:34 +00:00
if [ "$DEPLOY_NOSTR" = true ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
- nostrnet-$DOMAIN_IDENTIFIER-en
EOL
2023-04-04 14:56:34 +00:00
fi
2023-04-04 15:08:22 +00:00
fi
2023-03-06 19:30:56 +00:00
done
2023-04-04 15:08:22 +00:00
done
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
volumes:
2023-04-04 15:08:22 +00:00
- ${REMOTE_DATA_PATH_LETSENCRYPT}:/etc/letsencrypt:ro
2023-03-06 19:30:56 +00:00
EOL
2023-04-04 15:08:22 +00:00
if [ "$DEPLOY_CLAMS" = true ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-04-02 13:28:42 +00:00
- ${REMOTE_CLAMS_PATH}:/browser-app
2023-03-06 19:30:56 +00:00
EOL
2023-04-04 15:08:22 +00:00
fi
2023-03-06 19:30:56 +00:00
2023-04-04 15:08:22 +00:00
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
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
2023-04-04 15:08:22 +00:00
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
networks:
EOL
2023-04-04 15:08:22 +00:00
for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
export DOMAIN_NAME="$DOMAIN_NAME"
export SITE_PATH="$SITES_PATH/$DOMAIN_NAME"
2023-03-06 19:30:56 +00:00
2023-04-04 15:08:22 +00:00
# source the site path so we know what features it has.
source ../../../../defaults.sh
source "$SITE_PATH/site.conf"
source ../../domain_env.sh
2023-03-06 19:30:56 +00:00
2023-04-04 15:08:22 +00:00
# for each language specified in the site.conf, we spawn a separate ghost container
# at https://www.domain.com/$LANGUAGE_CODE
for LANGUAGE_CODE in ${SITE_LANGUAGE_CODES//,/ }; do
if [ "$DEPLOY_GHOST" = true ]; then
2023-03-06 19:30:56 +00:00
cat >> "$DOCKER_YAML_PATH" <<EOL
ghostnet-$DOMAIN_IDENTIFIER-$LANGUAGE_CODE:
attachable: true
EOL
2023-04-04 15:08:22 +00:00
fi
if [ "$LANGUAGE_CODE" = en ]; then
if [ "$DEPLOY_GITEA" = true ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
giteanet-$DOMAIN_IDENTIFIER-en:
attachable: true
EOL
2023-04-04 15:08:22 +00:00
fi
2023-03-06 19:30:56 +00:00
2023-04-04 15:08:22 +00:00
if [ "$DEPLOY_NEXTCLOUD" = true ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
nextcloudnet-$DOMAIN_IDENTIFIER-en:
attachable: true
EOL
2023-04-04 15:08:22 +00:00
fi
2023-03-06 19:30:56 +00:00
2023-04-04 14:56:34 +00:00
if [ "$DEPLOY_NOSTR" = true ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
2023-03-06 19:30:56 +00:00
nostrnet-$DOMAIN_IDENTIFIER-en:
attachable: true
EOL
2023-04-04 14:56:34 +00:00
2023-03-06 19:30:56 +00:00
fi
2023-04-04 15:08:22 +00:00
fi
done
done
2023-03-06 19:30:56 +00:00
if [ "$STOP_SERVICES" = false ]; then
2023-04-04 20:23:42 +00:00
# for some reason we need to wait here. See if there's a fix; poll for service readiness?
2023-04-05 19:44:26 +00:00
sleep 5
2023-04-04 20:23:42 +00:00
2023-04-04 15:08:22 +00:00
docker stack deploy -c "$DOCKER_YAML_PATH" reverse-proxy
2023-03-06 19:30:56 +00:00
# iterate over all our domains and create the nginx config file.
2023-04-04 15:08:22 +00:00
sleep 3
2023-03-06 19:30:56 +00:00
fi