From c4d5aec63e81db7706e21e7b4f7198073008538e Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Wed, 21 Jun 2023 08:12:49 +0200 Subject: [PATCH] run service inside docker as root, fix #329 --- debian/postinst | 4 ++++ docker/Dockerfile | 6 ++++-- docker/README.md | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/debian/postinst b/debian/postinst index 12f239ef..7c744de7 100644 --- a/debian/postinst +++ b/debian/postinst @@ -3,6 +3,10 @@ sysUser="ffpu" +if [ -f /run/.containerenv ] || [ -f /run/.dockerenv ] || [ -f /.dockerenv ] || [ -f /.dockerinit ]; then + sysUser="root" +fi + if [ ! $(id -u $sysUser 2>/dev/null || echo -1) -ge 0 ]; then adduser --system $sysUser fi diff --git a/docker/Dockerfile b/docker/Dockerfile index a6ea5ff1..050ce898 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,7 +14,7 @@ RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \ FROM base -ARG FFPLAYOUT_VERSION=0.18.3 +ARG FFPLAYOUT_VERSION=0.19.0 COPY README.md *.rpm /tmp/ RUN dnf update -y && \ @@ -29,7 +29,9 @@ RUN dnf update -y && \ RUN [[ -f /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm ]] || wget -q "https://github.com/ffplayout/ffplayout/releases/download/v${FFPLAYOUT_VERSION}/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm" -P /tmp/ && \ dnf install -y /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm && \ rm /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm && \ - mkdir -p /home/ffpu && chown -R ffpu: /home/ffpu && \ + sed -i "s/User=ffpu/User=root/g" /usr/lib/systemd/system/ffpapi.service && \ + sed -i "s/User=ffpu/User=root/g" /usr/lib/systemd/system/ffplayout.service && \ + sed -i "s/User=ffpu/User=root/g" /usr/lib/systemd/system/ffplayout@.service && \ systemctl enable ffplayout && \ systemctl enable ffpapi && \ ffpapi -u admin -p admin -m contact@example.com diff --git a/docker/README.md b/docker/README.md index 4860ce75..080b22b7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -34,6 +34,9 @@ How to build the image:\ # build default docker build -t ffplayout-image . +# build from root folder, to copy local *.rpm package +docker build -f docker/Dockerfile -t ffplayout-image:alma . + # build ffmpeg from source docker build -f fromSource.Dockerfile -t ffplayout-image:from-source . @@ -43,7 +46,7 @@ docker build -f Almalinux.Dockerfile -t ffplayout-image:almalinux . example of command to start the container: -`docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro --cap-add SYS_ADMIN -p 8787:8787 ffplayout-image` +`docker run -ti --name ffplayout -v /sys/fs/cgroup:/sys/fs/cgroup:ro --cap-add SYS_ADMIN -p 8787:8787 ffplayout-image` Note from CentOS docker hub page `