2022-09-28 22:20:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -exu
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
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.
|
2022-09-29 17:14:51 +00:00
|
|
|
source ../../../reset_env.sh
|
2022-09-28 22:20:17 +00:00
|
|
|
source "$SITE_PATH/site_definition"
|
2022-09-29 17:14:51 +00:00
|
|
|
source ../../../domain_env.sh
|
2022-09-28 22:20:17 +00:00
|
|
|
|
|
|
|
if [ "$DEPLOY_GITEA" = true ]; then
|
2022-09-29 17:14:51 +00:00
|
|
|
GITEA_PATH="$REMOTE_GITEA_PATH/$DOMAIN_NAME/${LANGUAGE_CODE}"
|
2022-09-28 22:20:17 +00:00
|
|
|
|
2022-10-08 16:44:46 +00:00
|
|
|
ssh "$PRIMARY_WWW_FQDN" mkdir -p "$GITEA_PATH/data" "$GITEA_PATH/db"
|
2022-09-28 22:20:17 +00:00
|
|
|
|
2022-09-29 17:14:51 +00:00
|
|
|
STACK_NAME="$DOCKER_STACK_SUFFIX-$LANGUAGE_CODE"
|
2022-09-28 22:20:17 +00:00
|
|
|
|
|
|
|
export STACK_TAG="gitea-$STACK_NAME"
|
|
|
|
export DB_STACK_TAG="giteadb-$STACK_NAME"
|
2022-10-08 16:44:46 +00:00
|
|
|
export DOCKER_YAML_PATH="$SITE_PATH/webstack/gitea-en.yml"
|
2022-09-28 22:20:17 +00:00
|
|
|
|
2022-09-29 17:14:51 +00:00
|
|
|
NET_NAME="giteanet-$DOCKER_STACK_SUFFIX"
|
|
|
|
DBNET_NAME="giteadbnet-$DOCKER_STACK_SUFFIX"
|
|
|
|
|
2022-09-28 22:20:17 +00:00
|
|
|
# here's the NGINX config. We support ghost and nextcloud.
|
|
|
|
echo "" > "$DOCKER_YAML_PATH"
|
|
|
|
cat >>"$DOCKER_YAML_PATH" <<EOL
|
|
|
|
version: "3.8"
|
|
|
|
services:
|
|
|
|
|
|
|
|
${STACK_TAG}:
|
|
|
|
image: ${GITEA_IMAGE}
|
|
|
|
volumes:
|
2022-09-29 17:14:51 +00:00
|
|
|
- ${GITEA_PATH}/data:/data
|
2022-09-28 22:20:17 +00:00
|
|
|
- /etc/timezone:/etc/timezone:ro
|
|
|
|
- /etc/localtime:/etc/localtime:ro
|
|
|
|
environment:
|
|
|
|
- USER_UID=1000
|
|
|
|
- USER_GID=1000
|
|
|
|
- ROOT_URL=https://${GITEA_FQDN}
|
|
|
|
- GITEA__database__DB_TYPE=mysql
|
|
|
|
- GITEA__database__HOST=${DB_STACK_TAG}:3306
|
|
|
|
- GITEA__database__NAME=gitea
|
|
|
|
- GITEA__database__USER=gitea
|
|
|
|
- GITEA__PASSWD=\${GITEA_MYSQL_PASSWORD}
|
|
|
|
networks:
|
2022-09-29 17:14:51 +00:00
|
|
|
- ${NET_NAME}
|
|
|
|
- ${DBNET_NAME}
|
2022-09-28 22:20:17 +00:00
|
|
|
deploy:
|
|
|
|
restart_policy:
|
|
|
|
condition: on-failure
|
|
|
|
|
|
|
|
${DB_STACK_TAG}:
|
|
|
|
image: ${GITEA_DB_IMAGE}
|
|
|
|
networks:
|
2022-09-29 17:14:51 +00:00
|
|
|
- ${DBNET_NAME}
|
2022-09-28 22:20:17 +00:00
|
|
|
volumes:
|
2022-09-29 17:14:51 +00:00
|
|
|
- ${GITEA_PATH}/db:/var/lib/mysql
|
2022-09-28 22:20:17 +00:00
|
|
|
environment:
|
|
|
|
- MYSQL_ROOT_PASSWORD=\${GITEA_MYSQL_ROOT_PASSWORD}
|
|
|
|
- MYSQL_PASSWORD=\${GITEA_MYSQL_PASSWORD}
|
|
|
|
- MYSQL_DATABASE=gitea
|
|
|
|
- MYSQL_USER=gitea
|
|
|
|
deploy:
|
|
|
|
restart_policy:
|
|
|
|
condition: on-failure
|
|
|
|
|
2022-09-29 17:14:51 +00:00
|
|
|
networks:
|
|
|
|
EOL
|
2022-09-28 22:20:17 +00:00
|
|
|
|
|
|
|
cat >>"$DOCKER_YAML_PATH" <<EOL
|
2022-09-29 17:14:51 +00:00
|
|
|
${NET_NAME}:
|
|
|
|
name: "reverse-proxy_${NET_NAME}-${LANGUAGE_CODE}"
|
|
|
|
external: true
|
|
|
|
|
|
|
|
${DBNET_NAME}:
|
2022-09-28 22:20:17 +00:00
|
|
|
EOL
|
|
|
|
|
2022-09-29 17:14:51 +00:00
|
|
|
docker stack deploy -c "$DOCKER_YAML_PATH" "$DOCKER_STACK_SUFFIX-gitea-$LANGUAGE_CODE"
|
2022-09-28 22:20:17 +00:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|