diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a04b86..b5b8dd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,4 +90,4 @@ jobs: run: | docker buildx build --push \ --tag ghcr.io/edenhaus/bumper:${{ steps.tag_name.outputs.tag }} \ - --platform linux/amd64,linux/arm/v7,linux/arm64 . + --platform linux/amd64 . diff --git a/Dockerfile b/Dockerfile index d09f2f4..9f772cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,18 @@ -ARG ARCH=amd64 +FROM python:3.10-alpine -FROM $ARCH/python:3.10-alpine +# set version for s6 overlay +ARG S6_OVERLAY_VERSION="3.1.2.1" +ARG S6_OVERLAY_ARCH="x86_64" + +# add s6 overlay +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp +RUN tar -C / -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz +ENTRYPOINT ["/init"] + +RUN apk add nginx +COPY root/ / EXPOSE 443 EXPOSE 5223 @@ -17,4 +29,4 @@ WORKDIR /bumper # Copy only required folders instead of all COPY bumper/ bumper/ -ENTRYPOINT ["python3", "-m", "bumper"] +CMD ["python3", "-m", "bumper"] diff --git a/root/etc/nginx.conf b/root/etc/nginx.conf new file mode 100644 index 0000000..ba5a6b4 --- /dev/null +++ b/root/etc/nginx.conf @@ -0,0 +1,40 @@ +error_log stderr; +pid /var/run/nginx.pid; + +events { } + +stream { + map_hash_bucket_size 64; + + map $ssl_preread_server_name $internalport { + # redirect all requests, which contain "mq" in the SNI -> MQTT + ~^.*(mq).*\.eco(vacs|user)\.(net|com)$ 8883; + + # the rest of eco(user|vacs) requests + ~^.*eco(vacs|user)\.(net|com)$ 443; + + # mapping default to MQTT as the bots are connecting directly to the ip without SNI + default 8883; + } + + server { + listen 443; + ssl_preread on; + proxy_pass 127.0.0.1:$internalport; + } + + server { + listen 5223; + proxy_pass 127.0.0.1:5223; + } + + server { + listen 8007; + proxy_pass 127.0.0.1:8007; + } + + server { + listen 8883; + proxy_pass 127.0.0.1:8883; + } +} \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/nginx/run b/root/etc/s6-overlay/s6-rc.d/nginx/run new file mode 100644 index 0000000..f14792d --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/nginx/run @@ -0,0 +1,2 @@ +#!/command/execlineb -P +nginx -g "daemon off;" \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/nginx/type b/root/etc/s6-overlay/s6-rc.d/nginx/type new file mode 100644 index 0000000..1780f9f --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/nginx/type @@ -0,0 +1 @@ +longrun \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/nginx b/root/etc/s6-overlay/s6-rc.d/user/contents.d/nginx new file mode 100644 index 0000000..e69de29