Skip to content

Commit

Permalink
[begin] repair paths inside pod.
Browse files Browse the repository at this point in the history
  • Loading branch information
c4lliope committed Aug 8, 2022
1 parent 6a82b84 commit a9d399e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
5 changes: 2 additions & 3 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ letsencrypt_configure_and_get_dir() {
# store config settings
echo "--http.port :$acme_port $config" >"$config_dir/config"

# send both host and container path
# to respect mapped DOKKU_ROOT when running in a container
echo "$DOKKU_HOST_ROOT/$app/letsencrypt/certs/$config_hash:$config_dir"
# respond using a "relative" address based on the dokku home.
echo "$app/letsencrypt/certs/$config_hash"
}

letsencrypt_get_email() {
Expand Down
12 changes: 6 additions & 6 deletions subcommands/enable
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ letsencrypt_acme() {
declare desc="perform actual ACME validation procedure"
declare app="$1" acme_port="$2"
local FAKE_NGINX_CONF=false
local config_dir

if [[ ! -f "$DOKKU_ROOT/$app/nginx.conf" ]]; then
FAKE_NGINX_CONF=true
Expand All @@ -84,20 +83,21 @@ letsencrypt_acme() {
dokku_log_info1 "Getting letsencrypt certificate for ${app}..."

# read arguments from appropriate config file into the config array
config_dirs="$(letsencrypt_configure_and_get_dir "$app" "$acme_port")"
host_config_dir="$(echo "$config_dirs" | cut -d: -f1)"
container_config_dir="$(echo "$config_dirs" | cut -d: -f2)"
read -r -a config <"$container_config_dir/config"
local config_dir=$(letsencrypt_configure_and_get_dir "$app" "$acme_port")
local config_dir_in_pod="/mnt/dokku/home/dokku/$config_dir"
local config_dir_on_host="$DOKKU_HOST_ROOT/$config_dir"
read -r -a config <"$config_dir_in_pod/config"

# run letsencrypt as a docker container using "certonly" mode
# port 80 of the standalone webserver will be forwarded by the proxy
set +e
export DOKKU_UID=$(id -u)
export DOKKU_GID=$(id -g)
docker run --rm \
"$PERMISSIONS_CALLS" \
--user $DOKKU_UID:$DOKKU_GID \
-p "$acme_port:$acme_port" \
-v "$host_config_dir:/certs" \
-v "$config_dir_on_host:/certs" \
"${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION}" \
"${config[@]}" run | sed "s/^/ /"

Expand Down
12 changes: 7 additions & 5 deletions subcommands/revoke
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@ letsencrypt_acme_revoke() {
local acme_port=$(get_available_port)

# read arguments from appropriate config file into the config array
config_dirs="$(letsencrypt_configure_and_get_dir "$app" "$acme_port")"
host_config_dir="$(echo "$config_dirs" | cut -d: -f1)"
container_config_dir="$(echo "$config_dirs" | cut -d: -f2)"
read -r -a config <"$container_config_dir/config"
local config_dir=$(letsencrypt_configure_and_get_dir "$app" "$acme_port")
local config_dir_in_pod="/mnt/dokku/home/dokku/$config_dir"
local config_dir_on_host="$DOKKU_HOST_ROOT/$config_dir"
read -r -a config <"$config_dir_in_pod/config"

# run letsencrypt as a docker container using "certonly" mode
# port 80 of the standalone webserver will be forwarded by the proxy
set +e
export DOKKU_UID=$(id -u)
export DOKKU_GID=$(id -g)

docker run --rm \
"$PERMISSIONS_CALLS" \
--user $DOKKU_UID:$DOKKU_GID \
-p "$acme_port:$acme_port" \
-v "$host_config_dir:/certs" \
-v "$config_dir_on_host:/certs" \
"${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION}" \
"${config[@]}" revoke | sed "s/^/ /"

Expand Down

0 comments on commit a9d399e

Please sign in to comment.