feat: Merge recorder and ffmpeg to base (#21)

## Description

**What(what issue does this code solve/what feature does it add):**
We do not need the ffmpeg and recorder all sitting differently, as this
will increase our docker image size
**How(how does it solve it):**

## Required Checklist:

- [ ] I have added any necessary documentation and comments in my code
(where appropriate)
- [ ] I have added tests to make sure my code runs in all contexts

## Further comments
This commit is contained in:
Wanjohi
2024-04-15 10:40:03 +03:00
committed by GitHub
parent 5d3d4acde7
commit e7f5666d7a
9 changed files with 70 additions and 143 deletions

View File

@@ -10,4 +10,7 @@ xhost
weston --backend=x11-backend.so
#Run inside the terminal of the weston you just created... cool right?
weston --backend=wayland-backend.so
weston --backend=wayland-backend.so
#Run
docker run --gpus all --entrypoint /bin/bash --rm -it -v $(pwd):/games -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY --cap-add=SYS_NICE --cap-add=SYS_ADMIN recorder

8
.github/labeler.yml vendored
View File

@@ -46,13 +46,9 @@ labels:
files:
- 'server.Dockerfile'
- label: 'scope/ffmpeg'
- label: 'scope/base'
files:
- 'ffmpeg.Dockerfile'
- label: 'scope/recorder'
files:
- 'recorder.Dockerfile'
- 'base.Dockerfile'
- label: 'scope/ffmpeg'
files:

5
.github/labels.yml vendored
View File

@@ -74,10 +74,7 @@
- name: "scope/relay"
color: "B61B66"
- name: "scope/ffmpeg"
color: "B61B66"
- name: "scope/recorder"
- name: "scope/base"
color: "B61B66"
- name: "scope/back-end"

View File

@@ -1,19 +1,19 @@
#Tabs not spaces, you moron :)
name: CI for netris:ffmpeg
name: CI for netris:base
on:
pull_request:
paths:
- "ffmpeg.Dockerfile"
- ".github/workflows/ffmpeg.yml"
- "base.Dockerfile"
- ".github/workflows/base.yml"
schedule:
- cron: 0 0 * * * # At the end of everyday
push:
branches: [main]
paths:
- "ffmpeg.Dockerfile"
- ".github/workflows/ffmpeg.yml"
- "base.Dockerfile"
- ".github/workflows/base.yml"
tags:
- v*.*.*
release:
@@ -26,7 +26,7 @@ concurrency:
env:
REGISTRY: ghcr.io
IMAGE_NAME: wanjohiryan/netris
BASE_TAG_PREFIX: ffmpeg
BASE_TAG_PREFIX: base
jobs:
build-docker-pr:
@@ -44,11 +44,11 @@ jobs:
name: Build Docker image
uses: docker/build-push-action@v5
with:
file: ffmpeg.Dockerfile
file: base.Dockerfile
context: ./
push: false
load: true
tags: netris:ffmpeg
tags: netris:base
build-docker-main:
name: Build image on merge
@@ -86,7 +86,7 @@ jobs:
name: Build Docker image
uses: docker/build-push-action@v5
with:
file: ffmpeg.Dockerfile
file: base.Dockerfile
context: ./
push: true
tags: ${{ steps.meta.outputs.tags }}

View File

@@ -1,93 +0,0 @@
#Tabs not spaces, you moron :)
name: CI for netris:recorder
on:
pull_request:
paths:
- "recorder.Dockerfile"
- ".github/workflows/recorder.yml"
schedule:
- cron: 0 0 * * * # At the end of everyday
push:
branches: [main]
paths:
- "recorder.Dockerfile"
- ".github/workflows/recorder.yml"
tags:
- v*.*.*
release:
types: [created]
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: wanjohiryan/netris
BASE_TAG_PREFIX: recorder
jobs:
build-docker-pr:
name: Build image on pr
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
-
name: Checkout repo
uses: actions/checkout@v4
-
name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build Docker image
uses: docker/build-push-action@v5
with:
file: recorder.Dockerfile
context: ./
push: false
load: true
tags: netris:recorder
build-docker-main:
name: Build image on merge
if: ${{github.ref == 'refs/heads/main'}}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
-
name: Checkout repo
uses: actions/checkout@v4
-
name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract Container metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ env.BASE_TAG_PREFIX }}
#
#tag on release, and a nightly build for 'dev'
tags: |
type=raw,value=nightly,enable={{is_default_branch}}
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Build Docker image
uses: docker/build-push-action@v5
with:
file: recorder.Dockerfile
context: ./
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@@ -1,9 +1,28 @@
#!/bin/bash
#Start pulseaudio
/usr/bin/pulseaudio --system --verbose --log-target=stderr --realtime=true --disallow-exit -F /etc/pulse/default.pa
# Attempt to set capabilities
# Gotten from https://git.dec05eba.com/gpu-screen-recorder/tree/install.sh
setcap 'cap_sys_admin+ep' /usr/bin/gsr-kms-server
setcap 'cap_sys_nice+ep' /usr/bin/gpu-screen-recorder
#TODO: remove this
# setcap 'cap_sys_admin+ep' /usr/bin/gsr-kms-server
# setcap 'cap_sys_nice+ep' /usr/bin/gpu-screen-recorder
#Start dbus
/etc/init.d/dbus start
#Start Pulseaudio Reference: https://github.com/wanjohiryan/warp/blob/ad9cd38d21f0ac4332e64358e219b48e01871870/docker/nvidia/entrypoint.sh#L38
/usr/bin/pulseaudio -k >/dev/null 2>&1 || /usr/bin/pulseaudio --system --verbose --log-target=stderr -D --realtime=true --disallow-exit -L 'module-native-protocol-tcp auth-ip-acl=127.0.0.0/8 port=4713 auth-anonymous=1'
pacmd load-module module-virtual-sink sink_name=vsink
pacmd set-default-sink vsink
pacmd set-default-source vsink.monitor
# Create and modify permissions of XDG_RUNTIME_DIR Reference: https://github.com/selkies-project/docker-nvidia-glx-desktop/blob/94b139c5d04395e1171202bb41e5d6f60e576a39/entrypoint.sh#L9C1-L10C1
mkdir -pm700 /tmp/runtime-user
chown root:root /tmp/runtime-user
chmod 700 /tmp/runtime-user
#FIXME:
#Mangohud [Works]
# Mangohud errors: Selected GPU 0: Tesla T4, type: DiscreteGpu [2024-04-14 23:52:57.098] [MANGOHUD] [error] [loader_nvctrl.cpp:39] Failed to open 64bit libXNVCtrl.so.0: libXNVCtrl.so.0: cannot open shared object file: No such file or directory [2024-04-14 23:52:57.098] [MANGOHUD] [error] [nvctrl.cpp:45] XNVCtrl loader failed to load
# gpu-screen-recorder [Fails]: #/usr/games/gamescope -w 1920 -h 1080 -W 3440 -H 1440 -r 60 -f -F fsr -- mangohud vkcubeNo CAP_SYS_NICE, falling back to regular-priority compute and threads.Performance will be affected.wlserver: [backend/headless/backend.c:68] Creating headless backendvulkan: selecting physical device 'Tesla T4': queue family 2vulkan: physical device does not support DRM format modifiersvulkan: physical device has no render nodeFailed to initialize Vulkan
# TODO: replace gpu-screen-recorder with shadow-cast (has better documentation)

View File

@@ -9,7 +9,6 @@ ENV DEBIAN_FRONTEND=noninteractive
# docker run --rm --cap-add SYS_ADMIN --cap-add SYS_NICE netris/gpu-screen-recorder
#Build and install gpu-screen-recorder
#TODO: Install ffmpeg
RUN apt-get update -y \
&& apt-get install -y \
curl \
@@ -22,6 +21,8 @@ RUN apt-get update -y \
cmake \
ccache \
bison \
software-properties-common \
ca-certificates \
equivs \
ca-certificates\
libcap2-bin \
@@ -29,19 +30,24 @@ RUN apt-get update -y \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libavfilter-dev \
libavdevice-dev \
libswresample-dev \
libswscale-dev \
libx11-dev \
libxcomposite-dev \
libkpipewire-dev \
libxrandr-dev \
libxfixes-dev \
libpulse-dev \
libswresample-dev \
libavfilter-dev \
libva-dev \
libcap-dev \
libdrm-dev \
libgl-dev \
libegl-dev \
libwayland-dev \
libnvidia-egl-wayland-dev \
libwayland-egl-backend-dev \
wayland-protocols \
&& rm -rf /var/lib/apt/lists/* \
@@ -53,4 +59,23 @@ RUN apt-get update -y \
&& echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf \
&& git clone https://repo.dec05eba.com/gpu-screen-recorder && cd gpu-screen-recorder \
&& chmod +x ./build.sh ./install.sh \
&& ./install.sh
&& ./install.sh
#Try building
RUN git clone https://github.com/gmbeard/shadow-cast && cd shadow-cast \
&& mkdir ./build && cd ./build \
&& cmake -DCMAKE_CXX_FLAGS="-Wno-error=unused-result" -DCMAKE_C_FLAGS="-Wno-error=unused-result" .. \
&& cmake --build . -- -j$(nproc) \
&& chmod +x ./install-helper.sh \
&& ./install-helper.sh
RUN apt-get update -y; \
apt-get upgrade -y; \
add-apt-repository ppa:savoury1/ffmpeg4 \
add-apt-repository ppa:savoury1/ffmpeg6 \
apt-get update -y; \
apt-get upgrade -y && apt-get dist-upgrade -y; \
apt-get install ffmpeg -y; \
#
# Log out the ffmpeg version
ffmpeg -version

View File

@@ -1,19 +0,0 @@
FROM ubuntu:23.10
RUN apt-get -yqq update \
&& apt-get install -yq --no-install-recommends \
software-properties-common \
ca-certificates \
&& apt-get autoremove -y \
&& apt-get clean -y
RUN apt-get update -y; \
apt-get upgrade -y; \
add-apt-repository ppa:savoury1/ffmpeg4 \
add-apt-repository ppa:savoury1/ffmpeg6 \
apt-get update -y; \
apt-get upgrade -y && apt-get dist-upgrade -y; \
apt-get install ffmpeg -y; \
#
# Log out the ffmpeg version
ffmpeg -version

View File

@@ -38,7 +38,7 @@ ENV PATH=/usr/local/nvidia/bin:${PATH} \
# Disable VSYNC
__GL_SYNC_TO_VBLANK=0
ENV XDG_RUNTIME_DIR=/run/user/1000/ \
ENV XDG_RUNTIME_DIR=/tmp/runtime-user \
# DISPLAY=:0 \
WAYLAND_DISPLAY=wayland-0 \
PUID=0 \
@@ -114,8 +114,7 @@ RUN apt-get update -y \
libasound2 \
libasound2-plugins \
pulseaudio \
&& rm -rf /var/lib/apt/lists/* \
&& echo "load-module module-native-protocol-tcp auth-anonymous=1" >> /etc/pulse/default.pa
&& rm -rf /var/lib/apt/lists/*
COPY .scripts/ /usr/bin/netris/
COPY warp /usr/bin/netris/