From 46175997e3f31e5ae3ca028c692218c28c64718f Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Apr 2022 22:47:54 +0700 Subject: [PATCH] add unit proxy on port 80 --- Dockerfile | 5 +++++ start.sh | 9 +++++++++ unitconfig.json | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 unitconfig.json diff --git a/Dockerfile b/Dockerfile index 29011b8..43bc899 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,11 @@ RUN apt-get update && apt-get install -y \ zlib1g-dev \ libjpeg-dev +RUN curl --output /usr/share/keyrings/nginx-keyring.gpg https://unit.nginx.org/keys/nginx-keyring.gpg && \ + echo "deb [signed-by=/usr/share/keyrings/nginx-keyring.gpg] https://packages.nginx.org/unit/ubuntu/ hirsute unit" > /etc/apt/sources.list.d/unit.list && \ + echo "deb-src [signed-by=/usr/share/keyrings/nginx-keyring.gpg] https://packages.nginx.org/unit/ubuntu/ hirsute unit" >> /etc/apt/sources.list.d/unit.list +RUN apt-get -y update && apt-get -y install unit + EXPOSE 5000 ARG tag=master diff --git a/start.sh b/start.sh index 60fbff3..cce11e9 100644 --- a/start.sh +++ b/start.sh @@ -1,2 +1,11 @@ +#Copy over Initial Printer Config cp -n /printer.cfg /home/octoprint/.octoprint/printer.cfg + +#Start Unit +unitd --no-daemon --control unix:/var/run/control-unit.sock & + +#Apply Primary Full Configuration +curl -X PUT --data-binary @/unitconfig.json --unix-socket /var/run/control-unit.sock http://localhost/config + +#Start OctoPrint and Klipper python3 /start.py \ No newline at end of file diff --git a/unitconfig.json b/unitconfig.json new file mode 100644 index 0000000..59829c3 --- /dev/null +++ b/unitconfig.json @@ -0,0 +1,18 @@ +{ + "listeners": { + "*:80": { + "pass": "routes" + } + }, + "routes": [ + { + "match": { + "uri": "*" + }, + + "action": { + "proxy": "http://127.0.0.1:5000" + } + } + ] +} \ No newline at end of file