Skip to content

Commit

Permalink
The major install shakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
erichlf committed May 3, 2024
1 parent cff3725 commit a8ebf86
Show file tree
Hide file tree
Showing 10 changed files with 732 additions and 419 deletions.
38 changes: 38 additions & 0 deletions docker/tvnamer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM debian:sid-slim

ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
LANGUAGE=en_US:en

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN set -x && \
KEPT_PACKAGES=() && \
# Packages kept in the image
KEPT_PACKAGES+=(bash) && \
KEPT_PACKAGES+=(ca-certificates) && \
KEPT_PACKAGES+=(locales) && \
KEPT_PACKAGES+=(locales-all) && \
KEPT_PACKAGES+=(python3) && \
KEPT_PACKAGES+=(python-is-python3) && \
KEPT_PACKAGES+=(python3-pip) && \
KEPT_PACKAGES+=(python3-pyxattr) && \
KEPT_PACKAGES+=(adduser) && \
# Install packages
apt-get update -y && \
apt-get install -y --no-install-recommends \
${KEPT_PACKAGES[@]} \
&& \
# Create /config directory
mkdir -p /config && \
# Clean-up
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/* /tmp/*
RUN rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED && \
pip3 install --no-cache tvnamer

# # Copy init script, set workdir, set configdir & entrypoint
COPY init /init
WORKDIR /workdir
ENTRYPOINT ["/init"]
37 changes: 37 additions & 0 deletions docker/tvnamer/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Create dockeruser homedir
mkdir -p /home/dockeruser

# Set UID/PID of user that youtube-dl will be run as
TVNAMERPGID=${PGID:-1000}
TVNAMERPUID=${PUID:-1000}

# Check to see if group/user already exist, if so, delete
EXISTINGGROUPNAME=$(getent group "$TVNAMERPGID" | cut -d ':' -f 1)
EXISTINGUSERNAME=$(getent passwd "$TVNAMERPUID" | cut -d ':' -f 1)
if [[ -n "$EXISTINGGROUPNAME" ]]; then
groupdel -f "$EXISTINGGROUPNAME"
fi
if [[ -n "$EXISTINGUSERNAME" ]]; then
userdel -f "$EXISTINGUSERNAME"
fi

# Create user/group
addgroup --quiet --gid "$TVNAMERPGID" dockeruser
chown -R "$TVNAMERPUID":"$TVNAMERPGID" /home/dockeruser
adduser --quiet --system --disabled-password --uid "$TVNAMERPUID" --gid "$TVNAMERPGID" --home /home/dockeruser dockeruser
HOME=/home/dockeruser
export HOME

# Set UMASK if required
if [[ -n "$UMASK" ]]; then
umask "$UMASK"
fi

# Run tvnamer with remainder of command line arguments
if [ -f /config/tvnamerconfig.json ]; then
setpriv --reuid dockeruser --regid dockeruser --keep-groups tvnamer -c /config/tvnamerconfig.json "$@"
else
setpriv --reuid dockeruser --regid dockeruser --keep-groups tvnamer "$@"
fi
Loading

0 comments on commit a8ebf86

Please sign in to comment.