diff --git a/camera-ustreamer/Dockerfile b/camera-ustreamer/Dockerfile index 2b6ffcf..be2a709 100644 --- a/camera-ustreamer/Dockerfile +++ b/camera-ustreamer/Dockerfile @@ -56,6 +56,9 @@ RUN mv janus/libjanus_ustreamer.so /opt/janus/lib/janus/plugins/libjanus_ustream FROM ${BUILD_FROM} AS final ENV LANG C.UTF-8 +COPY --from=builder /opt/janus /opt/janus +COPY --from=builder /usr/local/bin/ustreamer /usr/local/bin/ustreamer + RUN apk add -U \ alsa-lib \ curl \ @@ -80,9 +83,6 @@ RUN apk add -U \ zlib \ caddy -COPY --from=builder /opt/janus /opt/janus -COPY --from=builder /usr/local/bin/ustreamer /usr/local/bin/ustreamer - COPY rootfs/ / WORKDIR / diff --git a/camera-ustreamer/rootfs/etc/caddy/Caddyfile b/camera-ustreamer/rootfs/etc/caddy/Caddyfile index 278b20f..eaa6af7 100644 --- a/camera-ustreamer/rootfs/etc/caddy/Caddyfile +++ b/camera-ustreamer/rootfs/etc/caddy/Caddyfile @@ -1,4 +1,12 @@ -localhost +# Ingress +:8099 { + @blocked not remote_ip 172.30.32.2 + respond @blocked "This is only for access through Ingress" 403 + reverse_proxy 127.0.0.1:8080 +} -root * /server -file_server \ No newline at end of file +# External access +:8080 { + root * /opt/janus/share/janus/demos + file_server +} diff --git a/camera-ustreamer/rootfs/etc/cont-init.d/proxy.sh b/camera-ustreamer/rootfs/etc/cont-init.d/proxy.sh new file mode 100644 index 0000000..c84e750 --- /dev/null +++ b/camera-ustreamer/rootfs/etc/cont-init.d/proxy.sh @@ -0,0 +1,22 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: aiortc +# Configures NGINX for use with aiortc +# ============================================================================== + +# Generate Ingress configuration +bashio::var.json \ + interface "$(bashio::addon.ip_address)" \ + port "^$(bashio::addon.ingress_port)" \ + | tempio \ + -template /etc/nginx/templates/ingress.gtpl \ + -out /etc/nginx/servers/ingress.conf + +# Generate direct access configuration, if enabled. +if bashio::var.has_value "$(bashio::addon.port 80)"; then + bashio::var.json \ + port "^$(bashio::addon.port 80)" \ + | tempio \ + -template /etc/nginx/templates/direct.gtpl \ + -out /etc/nginx/servers/direct.conf +fi diff --git a/camera-ustreamer/rootfs/etc/services.d/janus/down b/camera-ustreamer/rootfs/etc/services.d/janus/down new file mode 100644 index 0000000..e69de29 diff --git a/camera-ustreamer/rootfs/etc/services.d/janus/run b/camera-ustreamer/rootfs/etc/services.d/janus/run new file mode 100644 index 0000000..fd58df9 --- /dev/null +++ b/camera-ustreamer/rootfs/etc/services.d/janus/run @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: camera-ustreamer +# Runs janus +# ============================================================================== + +bashio::log.info "Starting janus.." + +exec /opt/janus/bin/janus \ No newline at end of file diff --git a/camera-ustreamer/rootfs/etc/services.d/proxy/finish b/camera-ustreamer/rootfs/etc/services.d/proxy/finish deleted file mode 100644 index 382feb6..0000000 --- a/camera-ustreamer/rootfs/etc/services.d/proxy/finish +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/execlineb -S0 -# ============================================================================== -# Add-on: mjpg-streamer -# Take down the S6 supervision tree when Nginx fails -# ============================================================================== -if -n { s6-test $# -ne 0 } -if -n { s6-test ${1} -eq 256 } - -s6-svscanctl -t /var/run/s6/services diff --git a/camera-ustreamer/rootfs/etc/services.d/proxy/run b/camera-ustreamer/rootfs/etc/services.d/proxy/run index c792302..bf53c03 100644 --- a/camera-ustreamer/rootfs/etc/services.d/proxy/run +++ b/camera-ustreamer/rootfs/etc/services.d/proxy/run @@ -1,11 +1,8 @@ #!/usr/bin/with-contenv bashio # ============================================================================== -# Add-on: mjpg-streamer -# Runs the Nginx daemon +# Add-on: camera-ustreamer +# Runs the proxy daemon # ============================================================================== -# Wait for aiortc web server to be available -bashio::net.wait_for 80 - bashio::log.info "Starting proxy..." -# exec caddy run -config /etc/caddy/Caddyfile +exec caddy run -config /etc/caddy/Caddyfile diff --git a/camera-ustreamer/rootfs/etc/services.d/ustreamer/finish b/camera-ustreamer/rootfs/etc/services.d/ustreamer/finish index 1ecc5e9..0ef5ffe 100644 --- a/camera-ustreamer/rootfs/etc/services.d/ustreamer/finish +++ b/camera-ustreamer/rootfs/etc/services.d/ustreamer/finish @@ -1,7 +1,7 @@ #!/usr/bin/execlineb -S0 # ============================================================================== -# Add-on: mjpg-streamer -# Take down the S6 supervision tree when mjpg-streamer fails +# Add-on: camera-ustreamer +# Take down the S6 supervision tree when ustreamer fails # ============================================================================== if -n { s6-test $# -ne 0 } if -n { s6-test ${1} -eq 256 } diff --git a/camera-ustreamer/rootfs/etc/services.d/ustreamer/run b/camera-ustreamer/rootfs/etc/services.d/ustreamer/run index 52f5786..ff07ea4 100644 --- a/camera-ustreamer/rootfs/etc/services.d/ustreamer/run +++ b/camera-ustreamer/rootfs/etc/services.d/ustreamer/run @@ -6,4 +6,5 @@ bashio::log.info "Starting mjpg-streamer.." -mjpg_streamer -i "$(bashio::config 'mjpg_input')" -o "output_http.so -w /www_mjpg -p 80" +# mjpg_streamer -i "$(bashio::config 'mjpg_input')" -o "output_http.so -w /www_mjpg -p 80" +exec ustreamer --host=127.0.0.1 --port=80 \ No newline at end of file