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