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

@@ -11,3 +11,6 @@ weston --backend=x11-backend.so
#Run inside the terminal of the weston you just created... cool right? #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: files:
- 'server.Dockerfile' - 'server.Dockerfile'
- label: 'scope/ffmpeg' - label: 'scope/base'
files: files:
- 'ffmpeg.Dockerfile' - 'base.Dockerfile'
- label: 'scope/recorder'
files:
- 'recorder.Dockerfile'
- label: 'scope/ffmpeg' - label: 'scope/ffmpeg'
files: files:

5
.github/labels.yml vendored
View File

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

View File

@@ -1,19 +1,19 @@
#Tabs not spaces, you moron :) #Tabs not spaces, you moron :)
name: CI for netris:ffmpeg name: CI for netris:base
on: on:
pull_request: pull_request:
paths: paths:
- "ffmpeg.Dockerfile" - "base.Dockerfile"
- ".github/workflows/ffmpeg.yml" - ".github/workflows/base.yml"
schedule: schedule:
- cron: 0 0 * * * # At the end of everyday - cron: 0 0 * * * # At the end of everyday
push: push:
branches: [main] branches: [main]
paths: paths:
- "ffmpeg.Dockerfile" - "base.Dockerfile"
- ".github/workflows/ffmpeg.yml" - ".github/workflows/base.yml"
tags: tags:
- v*.*.* - v*.*.*
release: release:
@@ -26,7 +26,7 @@ concurrency:
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
IMAGE_NAME: wanjohiryan/netris IMAGE_NAME: wanjohiryan/netris
BASE_TAG_PREFIX: ffmpeg BASE_TAG_PREFIX: base
jobs: jobs:
build-docker-pr: build-docker-pr:
@@ -44,11 +44,11 @@ jobs:
name: Build Docker image name: Build Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
file: ffmpeg.Dockerfile file: base.Dockerfile
context: ./ context: ./
push: false push: false
load: true load: true
tags: netris:ffmpeg tags: netris:base
build-docker-main: build-docker-main:
name: Build image on merge name: Build image on merge
@@ -86,7 +86,7 @@ jobs:
name: Build Docker image name: Build Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
file: ffmpeg.Dockerfile file: base.Dockerfile
context: ./ context: ./
push: true push: true
tags: ${{ steps.meta.outputs.tags }} 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 #!/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 # Attempt to set capabilities
# Gotten from https://git.dec05eba.com/gpu-screen-recorder/tree/install.sh # Gotten from https://git.dec05eba.com/gpu-screen-recorder/tree/install.sh
setcap 'cap_sys_admin+ep' /usr/bin/gsr-kms-server #TODO: remove this
setcap 'cap_sys_nice+ep' /usr/bin/gpu-screen-recorder # 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 # docker run --rm --cap-add SYS_ADMIN --cap-add SYS_NICE netris/gpu-screen-recorder
#Build and install gpu-screen-recorder #Build and install gpu-screen-recorder
#TODO: Install ffmpeg
RUN apt-get update -y \ RUN apt-get update -y \
&& apt-get install -y \ && apt-get install -y \
curl \ curl \
@@ -22,6 +21,8 @@ RUN apt-get update -y \
cmake \ cmake \
ccache \ ccache \
bison \ bison \
software-properties-common \
ca-certificates \
equivs \ equivs \
ca-certificates\ ca-certificates\
libcap2-bin \ libcap2-bin \
@@ -29,19 +30,24 @@ RUN apt-get update -y \
libavcodec-dev \ libavcodec-dev \
libavformat-dev \ libavformat-dev \
libavutil-dev \ libavutil-dev \
libavfilter-dev \
libavdevice-dev \
libswresample-dev \
libswscale-dev \
libx11-dev \ libx11-dev \
libxcomposite-dev \ libxcomposite-dev \
libkpipewire-dev \
libxrandr-dev \ libxrandr-dev \
libxfixes-dev \ libxfixes-dev \
libpulse-dev \ libpulse-dev \
libswresample-dev \ libswresample-dev \
libavfilter-dev \
libva-dev \ libva-dev \
libcap-dev \ libcap-dev \
libdrm-dev \ libdrm-dev \
libgl-dev \ libgl-dev \
libegl-dev \ libegl-dev \
libwayland-dev \ libwayland-dev \
libnvidia-egl-wayland-dev \
libwayland-egl-backend-dev \ libwayland-egl-backend-dev \
wayland-protocols \ wayland-protocols \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
@@ -54,3 +60,22 @@ RUN apt-get update -y \
&& git clone https://repo.dec05eba.com/gpu-screen-recorder && cd gpu-screen-recorder \ && git clone https://repo.dec05eba.com/gpu-screen-recorder && cd gpu-screen-recorder \
&& chmod +x ./build.sh ./install.sh \ && 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 # Disable VSYNC
__GL_SYNC_TO_VBLANK=0 __GL_SYNC_TO_VBLANK=0
ENV XDG_RUNTIME_DIR=/run/user/1000/ \ ENV XDG_RUNTIME_DIR=/tmp/runtime-user \
# DISPLAY=:0 \ # DISPLAY=:0 \
WAYLAND_DISPLAY=wayland-0 \ WAYLAND_DISPLAY=wayland-0 \
PUID=0 \ PUID=0 \
@@ -114,8 +114,7 @@ RUN apt-get update -y \
libasound2 \ libasound2 \
libasound2-plugins \ libasound2-plugins \
pulseaudio \ pulseaudio \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/*
&& echo "load-module module-native-protocol-tcp auth-anonymous=1" >> /etc/pulse/default.pa
COPY .scripts/ /usr/bin/netris/ COPY .scripts/ /usr/bin/netris/
COPY warp /usr/bin/netris/ COPY warp /usr/bin/netris/