Fix bugs in create-service

This commit is contained in:
Tobias Reisinger 2023-06-13 11:09:53 +02:00
parent 76ec8b4ed9
commit 607ad23697
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE

View file

@ -38,15 +38,16 @@ parse_yn_str() {
# Create the env files
YAML_ENV=""
if parse_yn_bool "${CREATE_ENV_YN}" || parse_yn_bool "${CREATE_SECRET_ENV_YN}"; then
YAML_ENV="env_file:"
if parse_yn_bool "${CREATE_ENV}" || parse_yn_bool "${CREATE_SECRET_ENV}"; then
YAML_ENV="
env_file:"
fi
if parse_yn_bool "${CREATE_ENV_YN}"; then
if parse_yn_bool "${CREATE_ENV}"; then
YAML_ENV="${YAML_ENV}
- .env"
touch "${NAME}/.env"
fi
if parse_yn_bool "${CREATE_SECRET_ENV_YN}"; then
if parse_yn_bool "${CREATE_SECRET_ENV}"; then
YAML_ENV="${YAML_ENV}
- .secret.env"
touch "${NAME}/.secret.env"
@ -59,10 +60,9 @@ version: '3'
services:
app:
image: ${IMAGE}
restart: always
restart: always${YAML_ENV}
labels:
com.centurylinklabs.watchtower.enable: $(parse_yn_str "${WATCHTOWER}")
${YAML_ENV}
networks:
apps:
aliases:
@ -72,10 +72,18 @@ networks:
external: true
EOF
# Create the caddy config
cat <<EOF > "caddy/config/conf.${HOST}.d/${DOMAIN}.config"
caddy_path="caddy/config/conf.${HOST}.d"
if [ ! -d "${caddy_path}" ]; then
echo "Caddy config directory for host '${HOST}' not found, trying default"
caddy_path="caddy/config/conf.d"
fi
if [ -d "${caddy_path}" ]; then
cat <<EOF > "$caddy_path/${DOMAIN}.config"
${DOMAIN} {
import default
reverse_proxy ${SERVICE_NAME}:${PORT}
}
EOF
else
echo "Caddy config directory not found, skipping caddy config"
fi