Skip to content

Commit

Permalink
Merge pull request #328 from dokku/fix-non-deployed-support
Browse files Browse the repository at this point in the history
fix: correct issue where enabling letsencrypt for apps with no successful deploys errors out
  • Loading branch information
josegonzalez authored Apr 18, 2024
2 parents b7bc6e6 + 1b9b1b7 commit e8aeedb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 16 additions & 3 deletions internal-functions
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/certs/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/domains/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/nginx-vhosts/functions"
if [[ -f "$PLUGIN_CORE_AVAILABLE_PATH/nginx-vhosts/internal-functions" ]]; then
source "$PLUGIN_CORE_AVAILABLE_PATH/nginx-vhosts/internal-functions"
fi
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
Expand Down Expand Up @@ -336,6 +339,7 @@ fn-letsencrypt-cron-job-remove() {
fn-letsencrypt-create-root() {
declare desc="Ensure the let's encrypt root directory exists"
declare APP="$1"
local NGINX_ACCESS_LOG_FORMAT NGINX_ACCESS_LOG_PATH NGINX_ERROR_LOG_PATH

local app_root="$DOKKU_ROOT/$APP"
local le_root="$app_root/letsencrypt"
Expand All @@ -344,9 +348,18 @@ fn-letsencrypt-create-root() {

if [[ ! -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
dokku_log_info1 "Setting temporary site"
local NGINX_ACCESS_LOG_FORMAT="$(fn-nginx-access-log-format "$APP")"
local NGINX_ACCESS_LOG_PATH="$(fn-nginx-access-log-path "$APP")"
local NGINX_ERROR_LOG_PATH="$(fn-nginx-error-log-path "$APP")"
NGINX_ACCESS_LOG_FORMAT="$(fn-nginx-access-log-format "$APP")"
NGINX_ACCESS_LOG_PATH="$(fn-nginx-access-log-path "$APP")"
NGINX_ERROR_LOG_PATH="$(fn-nginx-error-log-path "$APP")"
if [[ -z "$NGINX_ACCESS_LOG_FORMAT" ]]; then
NGINX_ACCESS_LOG_FORMAT="$(fn-nginx-computed-access-log-format "$APP")"
fi
if [[ -z "$NGINX_ACCESS_LOG_PATH" ]]; then
NGINX_ACCESS_LOG_PATH="$(fn-nginx-computed-access-log-path "$APP")"
fi
if [[ -z "$NGINX_ERROR_LOG_PATH" ]]; then
NGINX_ERROR_LOG_PATH="$(fn-nginx-computed-error-log-path "$APP")"
fi

sigil -f "$PLUGIN_AVAILABLE_PATH/letsencrypt/templates/default-nginx.conf.sigil" \
DOMAINS="$(get_app_domains "$APP" | xargs)" DOKKU_ROOT="$DOKKU_ROOT" APP="$APP" \
Expand Down
4 changes: 2 additions & 2 deletions templates/default-nginx.conf.sigil
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ server {
listen 80;
server_name {{ .DOMAINS }};
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
access_log {{ $.NGINX_ACCESS_LOG_PATH }}{{ if and ($.NGINX_ACCESS_LOG_FORMAT) (ne $.NGINX_ACCESS_LOG_PATH "off") }} {{ $.NGINX_ACCESS_LOG_FORMAT }}{{ end }};
error_log {{ $.NGINX_ERROR_LOG_PATH }};
access_log {{ $.NGINX_ACCESS_LOG_PATH }}{{ if and ($.NGINX_ACCESS_LOG_FORMAT) (ne $.NGINX_ACCESS_LOG_PATH "off") }} {{ $.NGINX_ACCESS_LOG_FORMAT }}{{ end }};
error_log {{ $.NGINX_ERROR_LOG_PATH }};
}

0 comments on commit e8aeedb

Please sign in to comment.