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")"
|
|
|
|
|
2023-08-11 13:57:22 +00:00
|
|
|
docker pull "$NGINX_IMAGE"
|
|
|
|
|
2023-03-06 19:30:56 +00:00
|
|
|
#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.
|
2023-04-14 16:49:13 +00:00
|
|
|
source ../../../deployment_defaults.sh
|
2023-04-07 14:20:15 +00:00
|
|
|
source ../../project_defaults.sh
|
2023-04-04 15:08:22 +00:00
|
|
|
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-05-17 02:01:47 +00:00
|
|
|
EOL
|
|
|
|
|
2023-04-14 16:49:13 +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.
|
2023-04-14 16:49:13 +00:00
|
|
|
source ../../../deployment_defaults.sh
|
2023-04-07 14:20:15 +00:00
|
|
|
source ../../project_defaults.sh
|
2023-04-04 15:08:22 +00:00
|
|
|
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
|
|
|
|
2023-08-11 13:53:49 +00:00
|
|
|
# for some reason we need to wait here. See if there's a fix; poll for service readiness?
|
|
|
|
sleep 5
|
2023-04-04 20:23:42 +00:00
|
|
|
|
2023-08-11 13:53:49 +00:00
|
|
|
docker stack deploy -c "$DOCKER_YAML_PATH" reverse-proxy
|
|
|
|
# iterate over all our domains and create the nginx config file.
|
|
|
|
sleep 3
|