diff --git a/.env b/.env index d99ccca..8106d32 100644 --- a/.env +++ b/.env @@ -1,3 +1,5 @@ +COMPOSE_FILE="compose.yml:apps/obs/compose.yml" +HOSTNAME=desktop #CADDY_HTTP=127.0.0.1:80 #CADDY_HTTPS=127.0.0.1:443 #IPV4_NETWORK= diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f10862a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.env diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..baf0f96 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 SunRed + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/apps/obs/Dockerfile b/apps/obs/Dockerfile new file mode 120000 index 0000000..89d1c9e --- /dev/null +++ b/apps/obs/Dockerfile @@ -0,0 +1 @@ +Dockerfile.sway \ No newline at end of file diff --git a/apps/obs/Dockerfile.cage b/apps/obs/Dockerfile.cage new file mode 100644 index 0000000..74b73b6 --- /dev/null +++ b/apps/obs/Dockerfile.cage @@ -0,0 +1,10 @@ +FROM cagevnc:latest + +RUN pacman -Syu --noconfirm obs-studio \ + && yes y | pacman -Scc \ + && rm -rf /usr/share/man/* /usr/share/doc/* \ + /var/cache/pacman/pkg/* /var/lib/pacman/sync/* \ + /tmp/* + +ENV PAGE_TITLE="OBS Studio" \ + APP=obs diff --git a/apps/obs/Dockerfile.sway b/apps/obs/Dockerfile.sway new file mode 100644 index 0000000..4f44ee2 --- /dev/null +++ b/apps/obs/Dockerfile.sway @@ -0,0 +1,10 @@ +FROM swayvnc:latest + +RUN pacman -Syu --noconfirm obs-studio \ + && yes y | pacman -Scc \ + && rm -rf /usr/share/man/* /usr/share/doc/* \ + /var/cache/pacman/pkg/* /var/lib/pacman/sync/* \ + /tmp/* + +ENV PAGE_TITLE="OBS Studio" \ + APP=obs diff --git a/apps/obs/compose.yml b/apps/obs/compose.yml new file mode 100644 index 0000000..6287adc --- /dev/null +++ b/apps/obs/compose.yml @@ -0,0 +1,30 @@ +--- +x-restart-policy: &restart_policy + restart: unless-stopped +x-compose-defaults: &compose_defaults + <<: *restart_policy + networks: + desktop: + +services: + obs: + <<: *compose_defaults + build: + context: ./apps/obs + dockerfile: Dockerfile + image: obs-studio:latest + container_name: obs-studio + pull_policy: never + hostname: $HOSTNAME + links: + - guacd + volumes: + - ./user:/home/nobody + devices: + - /dev/dri:/dev/dri # for gpu acceleration + expose: + - 5900/tcp + +networks: + desktop: + external: true diff --git a/apps/obs/entrypoint.sh b/apps/obs/entrypoint.sh new file mode 100755 index 0000000..3e86d38 --- /dev/null +++ b/apps/obs/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +runuser -u user -- sh -c "exec env WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/10000 \ + WLR_BACKENDS=headless \ + WLR_NO_HARDWARE_CURSORS=1 \ + WLR_DRM_DEVICES=/dev/dri/card0 \ + /usr/bin/cage obs &" + +sleep 3s + +runuser -u user -- sh -c "exec env DISPLAY=:1 WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/10000 /usr/bin/wayvnc -C /etc/wayvnc/config -g" diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 82f2ce4..09405d6 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -1,11 +1,3 @@ -{ - servers { - protocol { - experimental_http3 - } - } -} - localhost { redir / /guacamole/ 308 reverse_proxy guacamole:8080 diff --git a/compose.yml b/compose.yml index 3a3fdf1..41d484f 100644 --- a/compose.yml +++ b/compose.yml @@ -20,15 +20,15 @@ services: - ${CADDY_HTTPS:-443}:443/udp # HTTP/3 volumes: - ./caddy/data:/data - - ./caddy/Caddyfile:/etc/caddy/Caddyfile + - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro guacd: <<: *compose_defaults image: guacamole/guacd:latest container_name: guacd volumes: - - ./guacamole/drive:/drive:rw - - ./guacamole/record:/record:rw + - ./guacamole/drive:/drive + - ./guacamole/record:/record guacamole: <<: *compose_defaults @@ -63,7 +63,7 @@ services: POSTGRES_PASSWORD: 'SuperSecretPassword1234' POSTGRES_USER: guacamole_user volumes: - - ./guacamole/init:/docker-entrypoint-initdb.d:z + - ./guacamole/init:/docker-entrypoint-initdb.d:ro - postgres:/var/lib/postgresql/data expose: - 5432/tcp diff --git a/prepare.sh b/prepare.sh index 950afb0..e56349b 100755 --- a/prepare.sh +++ b/prepare.sh @@ -1,18 +1,29 @@ #!/bin/sh -# check if docker is running +# Check if Docker is running if ! (docker ps >/dev/null 2>&1) then - echo "docker daemon not running, will exit here!" + echo "Docker daemon not running, exiting" exit fi read -e -p "Domain Guacamole should be served on [localhost]: " DOMAIN DOMAIN=${DOMAIN:-localhost} -sed -i "s/localhost/$DOMAIN/g" caddy/Caddyfile +sed -i "s/localhost/$DOMAIN/g" ./caddy/Caddyfile echo -n "Preparing folder guacamole/init and creating guacamole/init/initdb.sql ..." mkdir -p ./guacamole/init chmod -R +x ./guacamole/init docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --postgres > ./guacamole/init/initdb.sql echo "done" + +echo "Setting permissions for user directory (chown needs root)" +if $(sudo -v); then + mkdir -p ./user + sudo chown -R 10000:10000 ./user +else + echo "Sudo privileges not granted, skipped" +fi + +echo "everything done" +exit 0