From 3a89f07a6f37f5d878362cf969c7811c56440588 Mon Sep 17 00:00:00 2001 From: Izan Gil <66965250+SrIzan10@users.noreply.github.com> Date: Mon, 10 Nov 2025 21:40:56 +0100 Subject: [PATCH] chore: temp selfhosted migration + flv module refactors --- .github/workflows/docker.yml | 21 +-------------- .../src/content/docs/guides/start-stream.mdx | 2 +- dev/nginx.conf | 2 +- flv-module/Dockerfile | 18 +++---------- flv-module/docker-entrypoint.sh | 27 +++++++++++++++++++ 5 files changed, 33 insertions(+), 37 deletions(-) create mode 100644 flv-module/docker-entrypoint.sh diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d3fb3ad..17254ac 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -97,23 +97,4 @@ jobs: platforms: linux/amd64 secrets: | TURBO_TOKEN=${{ secrets.TURBO_TOKEN }} - TURBO_TEAM=${{ secrets.TURBO_TEAM }} - deploy: - name: Deploy to server - runs-on: ubuntu-latest - needs: [frontend, chat] - steps: - # source https://github.com/taciturnaxolotl/cachet/blob/main/.github/workflows/deploy.yaml - - name: Deploy with Docker - uses: appleboy/ssh-action@v1 - with: - host: hackclub.app - username: srizan - key: ${{ secrets.SSH_KEY }} - port: 22 - script: | - cd ~/compose/hctv - docker compose pull - docker compose up -d --remove-orphans - # for some reason, without the restart, the rtmp container stops working - docker compose restart \ No newline at end of file + TURBO_TEAM=${{ secrets.TURBO_TEAM }} \ No newline at end of file diff --git a/apps/docs/src/content/docs/guides/start-stream.mdx b/apps/docs/src/content/docs/guides/start-stream.mdx index b055395..a3e08a0 100644 --- a/apps/docs/src/content/docs/guides/start-stream.mdx +++ b/apps/docs/src/content/docs/guides/start-stream.mdx @@ -7,7 +7,7 @@ description: Get started with OBS and streaming on hackclub.tv - open settings - open "Stream" - set service to custom -- set url to `rtmp://hackclub.app:45913/live` +- set url to `rtmp://backend.hackclub.tv/live` - on the website, click "Regenerate key" - paste the key into your obs "Stream Key" - start streaming! diff --git a/dev/nginx.conf b/dev/nginx.conf index ff28157..fd6e01b 100644 --- a/dev/nginx.conf +++ b/dev/nginx.conf @@ -54,7 +54,7 @@ http { map $http_authorization $is_authorized { default 0; - $API_AUTH 1; + ${API_AUTH} 1; } server { diff --git a/flv-module/Dockerfile b/flv-module/Dockerfile index 12d81c43..9f01a1a 100644 --- a/flv-module/Dockerfile +++ b/flv-module/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.19 as builder +FROM alpine:3.19 AS builder RUN apk add --no-cache \ build-base \ @@ -37,20 +37,8 @@ RUN mkdir -p /etc/nginx/templates EXPOSE 80 1935 8888 -# Create an entrypoint script to handle environment variable substitution -RUN echo '#!/bin/sh \n\ -# Replace environment variables in configuration templates \n\ -for template in /etc/nginx/templates/*.conf.template; do \n\ - if [ -f "$template" ]; then \n\ - output_file="/usr/local/nginx/conf/$(basename $template .template)" \n\ - echo "Processing template: $template -> $output_file" \n\ - envsubst "$(env | awk -F= "{printf \\\"\\\$%s \\\",\\\$1}")" < $template > $output_file \n\ - fi \n\ -done \n\ -\n\ -# Start Nginx \n\ -exec "$@"' > /docker-entrypoint.sh && \ -chmod +x /docker-entrypoint.sh +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/flv-module/docker-entrypoint.sh b/flv-module/docker-entrypoint.sh new file mode 100644 index 0000000..27980d7 --- /dev/null +++ b/flv-module/docker-entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/sh +set -e + +UID=${UID:-1000} +GID=${GID:-1000} + +echo "Setting UID to $UID and GID to $GID" +usermod -u $UID nginx 2>/dev/null || echo "Failed to change UID" +groupmod -g $GID nginx 2>/dev/null || echo "Failed to change GID" + +mkdir -p /usr/local/nginx/conf +for template in /etc/nginx/templates/*.conf.template; do + if [ -f "$template" ]; then + output_file="/usr/local/nginx/conf/$(basename $template .template)" + echo "Processing template: $template -> $output_file" + envsubst '${API_AUTH}' < $template > $output_file + fi +done + +mkdir -p /usr/local/nginx/proxy_temp /usr/local/nginx/client_body_temp +mkdir -p /var/www/html +chown -R nginx:nginx /usr/local/nginx /var/www/html + +echo "Testing nginx configuration..." +/usr/local/nginx/sbin/nginx -t + +exec "$@" \ No newline at end of file