-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: non-root user for video recorder (#2122)
- Loading branch information
Showing
9 changed files
with
74 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,14 @@ ARG BASED_TAG | |
FROM $NAMESPACE/ffmpeg:$BASED_TAG | ||
LABEL authors="Selenium <[email protected]>" | ||
|
||
#Arguments to define the user running the container | ||
ARG SEL_USER=seluser | ||
ARG SEL_GROUP=${SEL_USER} | ||
ARG SEL_PASSWD=secret | ||
ARG UID=1200 | ||
ARG GID=1201 | ||
|
||
USER root | ||
#================================================ | ||
# Customize sources for apt-get | ||
#================================================ | ||
|
@@ -12,29 +20,69 @@ RUN echo "deb http://archive.ubuntu.com/ubuntu jammy main universe\n" > /etc/ap | |
|
||
# No interactive frontend during docker build | ||
ENV DEBIAN_FRONTEND=noninteractive \ | ||
DEBCONF_NONINTERACTIVE_SEEN=true | ||
DEBCONF_NONINTERACTIVE_SEEN=true \ | ||
PIP_ROOT_USER_ACTION=ignore | ||
|
||
#======================== | ||
# Supervisor | ||
#======================== | ||
RUN apt-get -qqy update \ | ||
&& apt-get upgrade -yq \ | ||
&& apt-get -qqy --no-install-recommends install \ | ||
supervisor x11-xserver-utils x11-utils curl jq python3-pip \ | ||
supervisor x11-xserver-utils x11-utils curl jq python3-pip tzdata acl \ | ||
&& python3 -m pip install --upgrade pip \ | ||
&& python3 -m pip install --upgrade setuptools \ | ||
&& python3 -m pip install --upgrade wheel \ | ||
&& python3 -m pip install psutil \ | ||
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* | ||
|
||
#=================== | ||
# Timezone settings | ||
# Possible alternative: https://github.com/docker/docker/issues/3359#issuecomment-32150214 | ||
#=================== | ||
ENV TZ "UTC" | ||
RUN ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \ | ||
dpkg-reconfigure -f noninteractive tzdata && \ | ||
cat /etc/timezone | ||
|
||
#====================================== | ||
# Configure environement | ||
#====================================== | ||
ENV SEL_USER=${SEL_USER} | ||
ENV SEL_UID=${UID} | ||
ENV SEL_GID=${GID} | ||
ENV HOME=/home/${SEL_USER} | ||
|
||
#======================================== | ||
# Add normal user and group with passwordless sudo | ||
#======================================== | ||
RUN groupadd ${SEL_GROUP} \ | ||
--gid ${SEL_GID} \ | ||
&& useradd ${SEL_USER} \ | ||
--create-home \ | ||
--gid ${SEL_GID} \ | ||
--shell /bin/bash \ | ||
--uid ${SEL_UID} \ | ||
&& usermod -a -G sudo ${SEL_USER} \ | ||
&& echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \ | ||
&& echo "${SEL_USER}:${SEL_PASSWD}" | chpasswd | ||
|
||
#====================================== | ||
# Add Supervisor configuration files | ||
#====================================== | ||
COPY supervisord.conf /etc | ||
COPY entry_point.sh video.sh video_ready.py /opt/bin/ | ||
RUN cd /opt/bin && pip install psutil | ||
COPY --chown="${SEL_UID}:${SEL_GID}" entry_point.sh video.sh video_ready.py /opt/bin/ | ||
|
||
ENV SE_VIDEO_FOLDER /videos | ||
RUN mkdir -p /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER | ||
RUN mkdir -p /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER \ | ||
&& chown -R ${SEL_USER}:${SEL_GROUP} /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME \ | ||
&& chmod -R 775 /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME \ | ||
&& chgrp -R 0 /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME \ | ||
&& chmod -R g=u /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME \ | ||
&& setfacl -Rdm u:${SEL_USER}:rwx,g:${SEL_GROUP}:rwx /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME | ||
|
||
USER ${SEL_UID} | ||
VOLUME ${SE_VIDEO_FOLDER} | ||
|
||
ENTRYPOINT ["/opt/bin/entry_point.sh"] | ||
CMD ["/opt/bin/entry_point.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.8.6-buster | ||
FROM python:3.10-slim | ||
|
||
WORKDIR /usr/src/app | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters