Use single file for Caddy

This commit is contained in:
Fredrik Baberg 2022-10-11 15:30:58 +02:00
parent dcc0a21404
commit 9f80b8afa5
6 changed files with 28 additions and 27 deletions

View File

@ -1,5 +1,5 @@
name: "3DPrinter-OctoPrint"
version: "2022.9.033"
version: "2022.10.0"
slug: "3dprinter-octoprint"
description: "OctoPrint as an addon, no additional bells and whistles."
url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint"
@ -30,4 +30,3 @@ schema:
camera_url: "url?"
recovery: "bool"
tmpfs: true
image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch}

View File

@ -2,6 +2,7 @@
debug
log {
format console
output file /var/log/caddy.log
}
}
import configs/*.caddy

View File

@ -5,7 +5,7 @@
# ==============================================================================
{ # Check if OctoPrint is installed.
octoprint --version
octoprint -b /data/config/octoprint --version
} || { # Otherwise install it.
{ # Check if Python is available (at `/data/python/octoprint` according to PATH)
python --version
@ -15,15 +15,13 @@
pip install wheel
}
pip install octoprint==$OCTOPRINT_VERSION
# Temporary bugfix, to be removed after 1.8.5 is released.
sed -i 's+//,+//g,+g' /data/python/octoprint/lib/python3.9/site-packages/octoprint/static/js/app/client/base.js
}
# Copy OctoPrint config to persistent storage, if missing.
if [ ! -f /data/config/octoprint/config.yaml ]; then
if [ -f /root/config/octoprint/config.yaml ]; then
mkdir -p /data/config/octoprint
# cp /root/config/octoprint/config.yaml /data/config/octoprint/config.yaml
cp /root/config/octoprint/config.yaml /data/config/octoprint/config.yaml
bashio::log.notice "Default OctoPrint config copied"
else
bashio::log.warning "Default OctoPrint config not found"

View File

@ -4,24 +4,13 @@
# Configures proxy
# ==============================================================================
mkdir -p /etc/caddy/configs
# Generate Ingress configuration
# Generate proxy configuration
bashio::var.json \
interface "$(bashio::addon.ip_address)" \
port "^$(bashio::addon.ingress_port)" \
external_port "^$(bashio::addon.port 5000)" \
ingress_entry "$(bashio::addon.ingress_entry)" \
camera_host "$(bashio::config 'camera_url')" \
| tempio \
-template /usr/share/tempio/Caddyfile.ingress.gtpl \
-out /etc/caddy/configs/ingress.caddy
# Generate direct access configuration, if enabled.
if bashio::var.has_value "$(bashio::addon.port 5000)"; then
bashio::var.json \
interface "$(bashio::addon.ip_address)" \
port "^$(bashio::addon.port 5000)" \
| tempio \
-template /usr/share/tempio/Caddyfile.direct.gtpl \
-out /etc/caddy/configs/direct.caddy
fi
-template /usr/share/tempio/Caddyfile.gtpl \
-out /etc/caddy/Caddyfile

View File

@ -1,6 +0,0 @@
# OctoPrint WebUI
:5000 {
reverse_proxy http://127.0.0.1:80 {
header_up X-Scheme {scheme}
}
}

View File

@ -1,9 +1,20 @@
{
debug
log {
format console
output file /var/log/caddy.log
}
}
:8099 {
@ingress {
remote_ip 172.30.32.2
}
uri strip_prefix {{ .ingress_entry }}
handle {
{{ if .recovery }}
rewrite / /recovery
{{ end }}
reverse_proxy @ingress 127.0.0.1:5000 {
header_up X-Script-Name {{ .ingress_entry }}
header_up -Origin
@ -14,3 +25,12 @@
}
}
}
{{ if .external_port }}
# OctoPrint WebUI
:5000 {
reverse_proxy http://127.0.0.1:5000 {
header_up X-Scheme {scheme}
}
}
{{ end }}