Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
d0u9 committed Mar 3, 2021
1 parent a33cd69 commit d5966f5
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 0 deletions.
56 changes: 56 additions & 0 deletions dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# For ubuntu, the latest tag points to the LTS version, since that is
# recommended for general use.
FROM python:3.6-slim

# grab gosu for easy step-down from root
ENV GOSU_VERSION 1.10
RUN set -x \
&& buildDeps=' \
unzip \
ca-certificates \
dirmngr \
wget \
xz-utils \
gpg \
' \
&& apt-get update && apt-get install -y --no-install-recommends $buildDeps \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true

# install ffmpeg
ENV FFMPEG_URL 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz'
RUN : \
&& mkdir -p /tmp/ffmpeg \
&& cd /tmp/ffmpeg \
&& wget -O ffmpeg.tar.xz "$FFMPEG_URL" \
&& tar -xf ffmpeg.tar.xz -C . --strip-components 1 \
&& cp ffmpeg ffmpeg-10bit ffprobe qt-faststart /usr/bin \
&& cd .. \
&& rm -fr /tmp/ffmpeg

# install youtube-dl-webui
ENV YOUTUBE_DL_WEBUI_SOURCE /usr/src/youtube_dl_webui
WORKDIR $YOUTUBE_DL_WEBUI_SOURCE

RUN : \
&& pip install --no-cache-dir youtube-dl flask \
&& wget -O youtube-dl-webui.zip https://github.com/d0u9/youtube-dl-webui/archive/dev.zip \
&& unzip youtube-dl-webui.zip \
&& cd youtube-dl-webui*/ \
&& cp -r ./* $YOUTUBE_DL_WEBUI_SOURCE/ \
&& ln -s $YOUTUBE_DL_WEBUI_SOURCE/example_config.json /etc/youtube-dl-webui.json \
&& cd .. && rm -rf youtube-dl-webui* \
&& apt-get purge -y --auto-remove wget unzip dirmngr \
&& rm -fr /var/lib/apt/lists/*

COPY docker-entrypoint.sh /usr/local/bin
COPY default_config.json /config.json
ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["python", "-m", "youtube_dl_webui"]
70 changes: 70 additions & 0 deletions dockerfile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# youtube-dl-webui

---

Visit [GitHub](https://github.com/d0u9/youtube-dl-webui) for more details.


## Install

1. From DockerHUB

docker pull d0u9/youtube-dl-webui

For china users, aliyun docker repo is more preferable:

docker pull registry.cn-hangzhou.aliyuncs.com/master/youtube-dl-webui


2. From DockerFile

cd /tmp
docker build -f </path/to/Dockerfile> -t youtube-dl-webui .

## Usage

1. Run container

docker run -d \
--name <container_name> \
-e PGID=<gid> \
-e PUID=<uid> \
-e PORT=port \
-e CONF_FILE=<config_file_in_container> \
-v <config_file>:<config_file_in_container> \
-p <host_port>:<port> \
-v <host_download_dir>:<download_dir> \
d0u9/youtube-dl-webui


2. Automatically start container after booting

Create `/etc/systemd/system/docker-youtube_dl_webui.service`, and fill
with the contents below:

[Unit]
Description=youtube-dl downloader
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a <container_name>
ExecStop=/usr/bin/docker stop -t 2 <container_name>

[Install]
WantedBy=default.target

## Default configurations

All defualt settings can be found in [this json file](https://github.com/d0u9/docker/blob/master/dockerfiles/youtube-dl-webui/default_config.json).

- Files save to: `/tmp/youtube_dl`;
- Database file location: `/tmp/youtube_dl_webui.db`;
- Log size: `10`;
- Listen address: `0.0.0.0`;
- Listen port: `5000`

---


13 changes: 13 additions & 0 deletions dockerfile/default_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"general": {
"download_dir": "/tmp/youtube_dl",
"db_path": "/tmp/youtube_dl_webui.db",
"log_size": 10
},
"server": {
"host": "0.0.0.0",
"port": 5000
},
"youtube_dl": {
}
}
16 changes: 16 additions & 0 deletions dockerfile/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

pgid=${PGID:-$(id -u root)}
puid=${PUID:-$(id -g root)}

conf=${CONF_FILE:-"/config.json"}
host=${HOST:-"0.0.0.0"}
port=${PORT:-5000}


if [[ "$*" == python*-m*youtube_dl_webui* ]]; then
exec gosu $puid:$pgid "$@" -c $conf --host $host --port $port
fi

exec "$@"

0 comments on commit d5966f5

Please sign in to comment.