modified: Dockerfile
new file: build_and_push.sh modified: init Script build & tag process. Make youtube-dl run as regular user.
This commit is contained in:
parent
26fd6011f6
commit
1b35543bc8
@ -35,16 +35,17 @@ FROM alpine:3.9 as final
|
|||||||
# Copy youtube-dl binary and manpage into container from builder container
|
# Copy youtube-dl binary and manpage into container from builder container
|
||||||
COPY --from=builder_ytdl /usr/local/bin/youtube-dl /usr/local/bin/youtube-dl
|
COPY --from=builder_ytdl /usr/local/bin/youtube-dl /usr/local/bin/youtube-dl
|
||||||
COPY --from=builder_ytdl /usr/local/man/man1/youtube-dl.1 /usr/local/man/man1/youtube-dl.1
|
COPY --from=builder_ytdl /usr/local/man/man1/youtube-dl.1 /usr/local/man/man1/youtube-dl.1
|
||||||
# Install & configure prerequisites for youtube-dl
|
# Install & configure s6 overlay, then prerequisites for youtube-dl
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add ffmpeg \
|
apk add ffmpeg \
|
||||||
rtmpdump \
|
rtmpdump \
|
||||||
mplayer \
|
mplayer \
|
||||||
mpv \
|
mpv \
|
||||||
python3 && \
|
python3 \
|
||||||
|
bash && \
|
||||||
ln -s /usr/bin/python3 /usr/bin/python && \
|
ln -s /usr/bin/python3 /usr/bin/python && \
|
||||||
youtube-dl --version && \
|
youtube-dl --version && \
|
||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/* /tmp/*
|
||||||
# Copy init script, set workdir & entrypoint
|
# Copy init script, set workdir & entrypoint
|
||||||
COPY init /init
|
COPY init /init
|
||||||
WORKDIR /workdir
|
WORKDIR /workdir
|
||||||
|
42
docker/build_and_push.sh
Executable file
42
docker/build_and_push.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
# Build "latest"
|
||||||
|
docker build . -t ytdl-org/youtube-dl:latest
|
||||||
|
build_exit=$?
|
||||||
|
|
||||||
|
|
||||||
|
# Get version of latest container
|
||||||
|
# Repeat as running straight after the build can give a 'bad interpreter: Text file busy' error
|
||||||
|
n=0
|
||||||
|
until [ $n -ge 5 ]
|
||||||
|
do
|
||||||
|
build_version=$(docker run --rm -ti ytdl-org/youtube-dl --version)
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
build_version=$(echo $build_version | sed 's/\r$//')
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
n=$[$n+1]
|
||||||
|
sleep 15
|
||||||
|
done
|
||||||
|
if [ $n -ge 5 ]; then
|
||||||
|
echo "Failed when trying to get youtube-dl version in latest container :("
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the build was successful, then we can tag with current version
|
||||||
|
if [ $build_exit -eq 0 ]; then
|
||||||
|
docker tag ytdl-org/youtube-dl:latest ytdl-org/youtube-dl:$build_version
|
||||||
|
tag_exit=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $build_exit -eq 0 ]; then
|
||||||
|
if [ $tag_exit -eq 0 ]; then
|
||||||
|
# If building and tagging was successful, then push
|
||||||
|
docker push ytdl-org/youtube-dl:latest
|
||||||
|
docker push ytdl-org/youtube-dl:$build_version
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Something went wrong..."
|
||||||
|
exit 1
|
25
docker/init
Normal file → Executable file
25
docker/init
Normal file → Executable file
@ -1,16 +1,17 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
|
export YOUTUBEDLARGS=$@
|
||||||
|
|
||||||
|
YOUTUBEDLPGID=${PGID:-1000}
|
||||||
|
YOUTUBEDLPUID=${PUID:-1000}
|
||||||
|
|
||||||
# Create dockeruser user/group
|
# Create dockeruser user/group
|
||||||
addgroup -g $PGID dockeruser
|
addgroup -g $YOUTUBEDLPGID dockeruser
|
||||||
adduser -D -u $PUID -G dockeruser -h /home/dockeruser dockeruser
|
adduser -D -u $YOUTUBEDLPUID -G dockeruser -h /home/dockeruser dockeruser
|
||||||
chown $PUID:$PGID /home/dockeruser
|
chown $YOUTUBEDLPUID:$YOUTUBEDLPGID /home/dockeruser
|
||||||
|
export HOME=/home/dockeruser
|
||||||
# Change ownership of youtube-dl and set sticky bit so youtube-dl runs as dockeruser (rootless operation)
|
|
||||||
chown $PUID:$PGID `which youtube-dl`
|
|
||||||
chmod u+s,g+s `which youtube-dl`
|
|
||||||
|
|
||||||
# Ensure .netrc has correct permissions (if present)
|
|
||||||
chown root:root /root/.netrc
|
|
||||||
|
|
||||||
# Run youtube-dl with remainder of command line arguments
|
# Run youtube-dl with remainder of command line arguments
|
||||||
youtube-dl $@
|
su -m dockeruser <<'EOF'
|
||||||
|
youtube-dl $YOUTUBEDLARGS
|
||||||
|
EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user