update
This commit is contained in:
@@ -31,9 +31,32 @@ require_env() {
|
||||
BROKER_DOMAIN="$(read_env_setting BROKER_DOMAIN)"
|
||||
GITEA_DOMAIN="$(read_env_setting GITEA_DOMAIN)"
|
||||
LETSENCRYPT_EMAIL="$(read_env_setting LETSENCRYPT_EMAIL)"
|
||||
SSL_MODE="$(read_env_setting SSL_MODE)"
|
||||
SSL_MODE="${SSL_MODE:-letsencrypt}"
|
||||
SSL_CERTIFICATE_DIR="$(read_env_setting SSL_CERTIFICATE_DIR)"
|
||||
SSL_CERTIFICATE_FILE="$(read_env_setting SSL_CERTIFICATE_FILE)"
|
||||
SSL_CERTIFICATE_KEY_FILE="$(read_env_setting SSL_CERTIFICATE_KEY_FILE)"
|
||||
SSL_CERTIFICATE_FILE="${SSL_CERTIFICATE_FILE:-fullchain.pem}"
|
||||
SSL_CERTIFICATE_KEY_FILE="${SSL_CERTIFICATE_KEY_FILE:-privkey.pem}"
|
||||
: "${BROKER_DOMAIN:?BROKER_DOMAIN is required}"
|
||||
: "${GITEA_DOMAIN:?GITEA_DOMAIN is required}"
|
||||
: "${LETSENCRYPT_EMAIL:?LETSENCRYPT_EMAIL is required}"
|
||||
case "$SSL_MODE" in
|
||||
letsencrypt)
|
||||
: "${LETSENCRYPT_EMAIL:?LETSENCRYPT_EMAIL is required for SSL_MODE=letsencrypt}"
|
||||
SSL_CERTIFICATE_DIR="${SSL_CERTIFICATE_DIR:-./config/letsencrypt/live/${BROKER_DOMAIN}}"
|
||||
;;
|
||||
custom)
|
||||
SSL_CERTIFICATE_DIR="${SSL_CERTIFICATE_DIR:-./config/ssl}"
|
||||
[[ -f "${SSL_CERTIFICATE_DIR}/${SSL_CERTIFICATE_FILE}" ]] ||
|
||||
fail "custom certificate was not found at ${SSL_CERTIFICATE_DIR}/${SSL_CERTIFICATE_FILE}"
|
||||
[[ -f "${SSL_CERTIFICATE_DIR}/${SSL_CERTIFICATE_KEY_FILE}" ]] ||
|
||||
fail "custom certificate key was not found at ${SSL_CERTIFICATE_DIR}/${SSL_CERTIFICATE_KEY_FILE}"
|
||||
;;
|
||||
*)
|
||||
fail "SSL_MODE must be letsencrypt or custom"
|
||||
;;
|
||||
esac
|
||||
export SSL_CERTIFICATE_DIR SSL_CERTIFICATE_FILE SSL_CERTIFICATE_KEY_FILE
|
||||
}
|
||||
|
||||
prepare() {
|
||||
@@ -42,6 +65,7 @@ prepare() {
|
||||
config/gitea/data \
|
||||
config/gitea/config \
|
||||
config/letsencrypt \
|
||||
config/ssl \
|
||||
config/certbot-webroot \
|
||||
config/backups
|
||||
chmod 700 config/broker config/gitea/data config/gitea/config config/backups
|
||||
@@ -66,12 +90,14 @@ bootstrap)
|
||||
prepare
|
||||
gitea_compose up -d
|
||||
docker compose up -d nginx
|
||||
docker compose --profile tools run --rm certbot certonly \
|
||||
--webroot --webroot-path /var/www/certbot \
|
||||
--non-interactive --agree-tos \
|
||||
--email "$LETSENCRYPT_EMAIL" \
|
||||
--cert-name "$BROKER_DOMAIN" \
|
||||
-d "$BROKER_DOMAIN" -d "$GITEA_DOMAIN"
|
||||
if [[ "$SSL_MODE" == "letsencrypt" ]]; then
|
||||
docker compose --profile tools run --rm certbot certonly \
|
||||
--webroot --webroot-path /var/www/certbot \
|
||||
--non-interactive --agree-tos \
|
||||
--email "$LETSENCRYPT_EMAIL" \
|
||||
--cert-name "$BROKER_DOMAIN" \
|
||||
-d "$BROKER_DOMAIN" -d "$GITEA_DOMAIN"
|
||||
fi
|
||||
docker compose -f compose.yaml -f compose.tls.yaml up -d nginx
|
||||
;;
|
||||
start)
|
||||
@@ -82,6 +108,8 @@ start)
|
||||
;;
|
||||
renew)
|
||||
require_env
|
||||
[[ "$SSL_MODE" == "letsencrypt" ]] ||
|
||||
fail "automatic renewal is only available with SSL_MODE=letsencrypt"
|
||||
docker compose --profile tools run --rm certbot renew --quiet
|
||||
docker compose -f compose.yaml -f compose.tls.yaml exec nginx nginx -s reload
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user