-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[octoprint-proxy] Migrate to nginx and editable config (#228)
* [octoprint-proxy] Migrate to nginx and editable config * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
fe85d40
commit cc7bbbf
Showing
12 changed files
with
90 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
ARG BUILD_FROM | ||
ARG BUILD_FROM=ghcr.io/hassio-addons/base:13.0.0 | ||
FROM $BUILD_FROM | ||
|
||
ENV LANG C.UTF-8 | ||
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=30000 | ||
ENV S6_KEEP_ENV=1 | ||
|
||
RUN apk add haproxy | ||
RUN apk add nginx inotify-tools | ||
|
||
COPY run.sh haproxy.cfg / | ||
RUN rm /etc/nginx/http.d/default.conf | ||
|
||
RUN chmod a+x /run.sh | ||
CMD [ "/run.sh" ] | ||
COPY root / | ||
|
||
RUN ln -s /octoprint /config | ||
|
||
# RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,20 @@ | ||
name: OctoPrint Proxy | ||
version: 1.0.2 | ||
name: OctoPrint Proxy (NOT WORKING) | ||
version: 1.0.3 | ||
slug: octoprint_proxy | ||
description: Access OctoPrint from within Home Assistant | ||
url: https://github.com/MaxWinterstein/homeassistant-addons/ | ||
image: ghcr.io/maxwinterstein/homeassistant-addon-octoprint-proxy-{arch} | ||
ingress: true | ||
ingress_port: 80 | ||
ingress_port: 8055 | ||
ingress_entry: login | ||
panel_title: OctoPrint | ||
panel_icon: mdi:printer-3d-nozzle | ||
arch: | ||
- armv7 | ||
- aarch64 | ||
- amd64 | ||
init: false | ||
options: | ||
octoprint_host: octopi | ||
octoprint_port: "443" | ||
ssl: | ||
enabled: true | ||
verify: false | ||
schema: | ||
octoprint_host: str | ||
octoprint_port: port | ||
ssl: | ||
enabled: bool | ||
verify: bool | ||
map: | ||
- addon_config:rw | ||
ports: | ||
8055/tcp: 8055 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
########### | ||
|
||
sh -c "nginxReloader.sh &" | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
########### | ||
|
||
while true | ||
do | ||
inotifywait --exclude .swp -e create -e modify -e delete -e move /etc/nginx/conf.d | ||
nginx -t | ||
if [ $? -eq 0 ] | ||
then | ||
echo "Detected Nginx Configuration Change" | ||
echo "new config:" | ||
nginx -T | ||
echo "Executing: nginx -s reload" | ||
nginx -s reload | ||
fi | ||
done |
22 changes: 22 additions & 0 deletions
22
octoprint-proxy/root/etc/s6-overlay/s6-rc.d/nginx-reloader/run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/with-contenv bashio | ||
|
||
bashio::log.blue "Starting reloader..." | ||
|
||
set -x | ||
# set +e | ||
|
||
while true | ||
do | ||
MYWAIT=$(inotifywait -e modify /config/nginx.conf) | ||
bashio::log.blue "$(date '+%Y-%m-%d %H:%M:%S') $MYWAIT" | ||
nginx -t | ||
if [ $? -eq 0 ] | ||
then | ||
bashio::log.blue "Detected Nginx Configuration Change" | ||
bashio::log.blue "Executing: nginx -s reload" | ||
nginx -s reload | ||
else | ||
bashio::log.blue "wtf?" | ||
|
||
fi | ||
done |
1 change: 1 addition & 0 deletions
1
octoprint-proxy/root/etc/s6-overlay/s6-rc.d/nginx-reloader/type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
longrun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/with-contenv bashio | ||
|
||
bashio::log.green 'starting nginx' | ||
|
||
test -f /config/nginx.conf || cat <<EOF > /config/nginx.conf | ||
server { | ||
listen 8080; | ||
|
||
server_name your_domain www.your_domain; | ||
|
||
location / { | ||
proxy_pass app_server_address; | ||
include proxy_params; | ||
} | ||
} | ||
EOF | ||
|
||
test -f /etc/nginx/http.d/proxy.conf || ln -s /config/nginx.conf /etc/nginx/http.d/proxy.conf | ||
|
||
nginx -t | ||
nginx | ||
echo sleep | ||
sleep 999 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
longrun |
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.