run service inside docker as root, fix #329

This commit is contained in:
jb-alvarado 2023-06-21 08:12:49 +02:00
parent 7c398c5e55
commit c4d5aec63e
3 changed files with 12 additions and 3 deletions

4
debian/postinst vendored
View File

@ -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

View File

@ -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

View File

@ -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
`