From fd87a0adae6130f6d2d391fc2faa50e000ef3bb7 Mon Sep 17 00:00:00 2001 From: Jerry Aldrich Date: Thu, 3 Nov 2022 21:23:33 -0700 Subject: [PATCH] Update to use lighttpd --- client/Dockerfile | 26 +++++++++----------------- client/entrypoint.sh | 13 ++++++------- client/lighttpd.conf | 23 ----------------------- content/Dockerfile | 14 ++++---------- content/cors.conf | 3 +++ content/lighttpd.conf | 28 ---------------------------- docker-compose.yaml | 7 ++----- 7 files changed, 24 insertions(+), 90 deletions(-) mode change 100644 => 100755 client/entrypoint.sh delete mode 100644 client/lighttpd.conf create mode 100644 content/cors.conf delete mode 100644 content/lighttpd.conf diff --git a/client/Dockerfile b/client/Dockerfile index 738392e..70cf568 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -4,26 +4,18 @@ RUN apk add --no-cache git WORKDIR /src -RUN git clone --depth=1 --recurse-submodules https://github.com/glennhartmann/quakejs +RUN git clone --depth=1 https://github.com/glennhartmann/quakejs -FROM alpine:latest +FROM jerryaldrichiii/lighttpd:1.4.64-r0 -RUN apk add --no-cache lighttpd - -RUN chown -R lighttpd /var/log/lighttpd -COPY lighttpd.conf /etc/lighttpd/lighttpd.conf - -COPY --from=build /src/quakejs/html/ /srv/http/ -RUN chown -R lighttpd /srv - -COPY index.html.template /bootstrap/index.html.template -RUN chown -R lighttpd /bootstrap +EXPOSE 8080 -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh +COPY --from=build /src/quakejs/html/ /srv/html/ USER lighttpd +RUN rm /srv/html/index.html -EXPOSE 8080 -ENTRYPOINT ["/entrypoint.sh"] -CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"] +RUN mkdir -p /tmp/bootstrap +COPY index.html.template /tmp/bootstrap/index.html.template + +COPY entrypoint.sh /docker-entrypoint.d/10-quakejs-client.sh diff --git a/client/entrypoint.sh b/client/entrypoint.sh old mode 100644 new mode 100755 index b29afd0..c18065f --- a/client/entrypoint.sh +++ b/client/entrypoint.sh @@ -3,15 +3,14 @@ # Exit on error set -e -sed -i "s/QUAKEJS_TAB_TITLE/${QUAKEJS_TAB_TITLE:=Quake JS}/" /bootstrap/index.html.template -sed -i "s/QUAKEJS_CONTENT_URL/${QUAKEJS_CONTENT_URL:=content.quakejs.com}/" /bootstrap/index.html.template -sed -i "s/QUAKEJS_SERVER_URL/$QUAKEJS_SERVER_URL/" /bootstrap/index.html.template +sed -i "s/QUAKEJS_TAB_TITLE/${QUAKEJS_TAB_TITLE:=Quake JS}/" /tmp/bootstrap/index.html.template +sed -i "s/QUAKEJS_CONTENT_URL/${QUAKEJS_CONTENT_URL:=content.quakejs.com}/" /tmp/bootstrap/index.html.template +sed -i "s/QUAKEJS_SERVER_URL/$QUAKEJS_SERVER_URL/" /tmp/bootstrap/index.html.template if [ -n "$QUAKEJS_USE_SSL" ]; then - sed -i "s/'http:\/\/'/\'https:\/\/'/g" /srv/http/ioquake3.js - sed -i "s/'ws:\/\/'/\'wss:\/\/'/g" /srv/http/ioquake3.js + sed -i "s/'http:\/\/'/\'https:\/\/'/g" /srv/html/ioquake3.js + sed -i "s/'ws:\/\/'/\'wss:\/\/'/g" /srv/html/ioquake3.js fi -cp /bootstrap/index.html.template /srv/http/index.html +cp -f /tmp/bootstrap/index.html.template /srv/html/index.html -lighttpd -D -f /etc/lighttpd/lighttpd.conf diff --git a/client/lighttpd.conf b/client/lighttpd.conf deleted file mode 100644 index fb02a50..0000000 --- a/client/lighttpd.conf +++ /dev/null @@ -1,23 +0,0 @@ -var.logdir = "/var/log/lighttpd" -var.statedir = "/var/lib/lighttpd" - -server.modules = ( - "mod_access", - "mod_accesslog", -) - -include "mime-types.conf" - -server.document-root = "/srv/http/" -server.pid-file = "/tmp/lighttpd.pid" - -server.errorlog-use-syslog = "enable" -accesslog.use-syslog = "enable" - -server.indexfiles = ("index.php", "index.html", "index.htm", "default.htm") - -server.port = 8080 - -url.access-deny = ("~", ".inc") - -server.network-backend = "writev" diff --git a/content/Dockerfile b/content/Dockerfile index d959686..55c3120 100644 --- a/content/Dockerfile +++ b/content/Dockerfile @@ -8,17 +8,11 @@ RUN wget https://steamforge.net/files/quakejs/get_assets.sh RUN bash get_assets.sh -FROM alpine:latest +FROM jerryaldrichiii/lighttpd:1.4.64-r0 -RUN apk add --no-cache lighttpd - -RUN chown -R lighttpd /var/log/lighttpd - -USER lighttpd +EXPOSE 8080 -COPY lighttpd.conf /etc/lighttpd/lighttpd.conf -COPY --from=build /src/assets /srv/http/assets +COPY cors.conf /etc/lighttpd/conf.d/cors.conf -EXPOSE 8080 +COPY --from=build /src/assets /srv/html/assets -CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"] diff --git a/content/cors.conf b/content/cors.conf new file mode 100644 index 0000000..8ea86e2 --- /dev/null +++ b/content/cors.conf @@ -0,0 +1,3 @@ +setenv.add-response-header = ( + "Access-Control-Allow-Origin" => "*", +) diff --git a/content/lighttpd.conf b/content/lighttpd.conf deleted file mode 100644 index fbec07f..0000000 --- a/content/lighttpd.conf +++ /dev/null @@ -1,28 +0,0 @@ -var.logdir = "/var/log/lighttpd" -var.statedir = "/var/lib/lighttpd" - -server.modules = ( - "mod_access", - "mod_accesslog", - "mod_setenv", -) - -setenv.add-response-header = ( - "Access-Control-Allow-Origin" => "*", -) - -include "mime-types.conf" - -server.document-root = "/srv/http/" -server.pid-file = "/tmp/lighttpd.pid" - -server.errorlog-use-syslog = "enable" -accesslog.use-syslog = "enable" - -server.indexfiles = ("index.php", "index.html", "index.htm", "default.htm") - -server.port = 8080 - -url.access-deny = ("~", ".inc") - -server.network-backend = "writev" diff --git a/docker-compose.yaml b/docker-compose.yaml index 9e1425f..0270fa4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,8 +13,7 @@ services: depends_on: - content - server - #build: client/ - image: nginxinc/nginx-unprivileged + build: client/ ports: - "8080:8080" environment: @@ -22,11 +21,9 @@ services: - "QUAKEJS_CONTENT_URL=172.16.69.1:9999" # Prevent subnet conflict with OpenVPN -# Can connect to services via 172.69.0.1:PORT -# NOTE: localhost:8080 will no longer work networks: default: ipam: driver: default config: - - subnet: 172.16.69.0/16 + - subnet: 172.16.69.0/24