diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..baad3ea --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '2' + +services: + web-frontend: + build: + # build from Dockerfile + context: ./tiling-frontend + dockerfile: Dockerfile + volumes: + - tiling_frontend_build:/usr/src/app/dist + obs: + build: + context: ./obs + dockerfile: Dockerfile + volumes: + - tiling_frontend_build:/home/obs/html +volumes: + tiling_frontend_build: diff --git a/obs/Dockerfile b/obs/Dockerfile new file mode 100644 index 0000000..8bd3fea --- /dev/null +++ b/obs/Dockerfile @@ -0,0 +1,35 @@ +FROM docker.io/ubuntu:noble + +ENV OBSWS_PASSWORD="" + +RUN apt update && \ +apt install software-properties-common -y && \ +add-apt-repository ppa:obsproject/obs-studio -y && \ +apt update && \ +apt install ffmpeg obs-studio -y + +RUN apt install python3-pip python3-venv xvfb -y + +RUN useradd -ms /bin/bash obs + +USER obs + +RUN mkdir -p /home/obs/.config/obs-studio/basic/profiles/Untitled + +RUN echo -e "\n[OBSWebSocket]\nFirstLoad=false\nServerEnabled=true\nServerPort=4455\nAlertsEnabled=false\nAuthRequired=true\nServerPassword=${OBSWS_PASSWORD}\n" >> /home/obs/.config/obs-studio/global.ini + +RUN echo '{"type":"rtmp_common","settings":{"service":"YouTube - RTMPS","protocol":"RTMPS","server":"rtmps://a.rtmps.youtube.com:443/live2","bwtest":false,"key":"${YT_STREAM_KEY}","stream_key_link":"https://www.youtube.com/live_dashboard","multitrack_video_name":"Multitrack Video","multitrack_video_disclaimer":"Multitrack Video automatically optimizes your settings to encode and send multiple video qualities to YouTube - RTMPS. Selecting this option will send YouTube - RTMPS information about your computer and software setup."}}' > /home/obs/.config/obs-studio/basic/profiles/Untitled/service.json + +COPY requirements.txt /home/obs + +RUN python3 -m venv /home/obs/.venv + +RUN /home/obs/.venv/bin/pip install -r /home/obs/requirements.txt + +COPY start.sh /home/obs + +COPY setup-obs.py /home/obs + +RUN echo $OBSWS_PASSWORD + +ENTRYPOINT /home/obs/start.sh diff --git a/obs/requirements.txt b/obs/requirements.txt new file mode 100644 index 0000000..70cf20c --- /dev/null +++ b/obs/requirements.txt @@ -0,0 +1 @@ +obsws-python diff --git a/obs/setup-obs.py b/obs/setup-obs.py new file mode 100644 index 0000000..09381c2 --- /dev/null +++ b/obs/setup-obs.py @@ -0,0 +1,14 @@ +import obsws_python as obs +import os + +# pass conn info if not in config.toml +client = obs.ReqClient(host='localhost', port=4455, password=os.environ["OBSWS_PASSWORD"]) + +scene = client.get_scene_list().scenes[0]['sceneName'] + +inputs = client.get_scene_item_list(name=scene).scene_items + +print(client.get_input_default_settings("browser_source").default_input_settings) + +if inputs == []: + client.create_input(sceneName=scene, inputName="Browser", inputKind="browser_source", inputSettings={'css': 'body { margin: 0px auto; overflow: hidden; }', 'fps': 30, 'fps_custom': True, 'height': 1080, 'is_local_file': True, 'local_file': '/home/micha/index.html', 'reroute_audio': True, 'restart_when_active': False, 'shutdown': False, 'webpage_control_level': 0, 'width': 1920}, sceneItemEnabled=True) diff --git a/obs/start.sh b/obs/start.sh new file mode 100755 index 0000000..0128d74 --- /dev/null +++ b/obs/start.sh @@ -0,0 +1,9 @@ +#!/usr/bin/bash + +export DISPLAY=:99 +Xvfb $DISPLAY & +obs & +sleep 1 +source /home/obs/.venv/bin/activate +python3 /home/obs/setup-obs.py + diff --git a/requirements.txt b/requirements.txt index b5a1063..0f1543e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ requests python-dotenv prisma fastapi-utils -httpx \ No newline at end of file +httpx +obsws-python diff --git a/tiling-frontend/.dockerignore b/tiling-frontend/.dockerignore new file mode 100644 index 0000000..f965aed --- /dev/null +++ b/tiling-frontend/.dockerignore @@ -0,0 +1,15 @@ +node_modules +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +README.md +LICENSE +.vscode +Makefile +helm-charts +.env +.editorconfig +.idea +coverage* diff --git a/tiling-frontend/Dockerfile b/tiling-frontend/Dockerfile new file mode 100644 index 0000000..969c7b6 --- /dev/null +++ b/tiling-frontend/Dockerfile @@ -0,0 +1,16 @@ +FROM docker.io/oven/bun:slim AS base +WORKDIR /usr/src/app + +FROM base AS install +RUN mkdir -p /temp/dev +COPY package.json bun.lockb /temp/dev/ +RUN cd /temp/dev && bun install + +RUN mkdir -p /temp/prod +COPY package.json bun.lockb /temp/prod/ +RUN cd /temp/prod && bun install --production + +FROM base AS release +COPY --from=install /temp/dev/node_modules node_modules +COPY . . +RUN bun --bun run build diff --git a/tiling-frontend/bun.lockb b/tiling-frontend/bun.lockb index ac9ea20..b65cb8f 100755 Binary files a/tiling-frontend/bun.lockb and b/tiling-frontend/bun.lockb differ diff --git a/tiling-frontend/package.json b/tiling-frontend/package.json index be14666..fe3c93c 100644 --- a/tiling-frontend/package.json +++ b/tiling-frontend/package.json @@ -25,5 +25,8 @@ "hls.js": "^1.5.13", "unocss": "^0.61.3", "vite-plugin-singlefile": "^2.0.2" - } + }, + "trustedDependencies": [ + "svelte-preprocess" + ] }