From ee62fb9aa192e668136862d5e23d3a6b11338169 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sun, 22 Oct 2023 00:14:44 -0700 Subject: [PATCH] [DOCKER] GUI Docker image using Code-Server --- .gitignore | 1 + Makefile | 4 +- docker/Dockerfile.gui | 85 +++++++++++++++++++++++++++ docker/root/etc/cont-init.d/30-config | 15 +++-- docker/testing/docker-compose.yml | 13 ++++ src/ytdl_sub/__init__.py | 4 +- 6 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 docker/Dockerfile.gui create mode 100644 docker/testing/docker-compose.yml diff --git a/.gitignore b/.gitignore index 4d638c33..d467a238 100644 --- a/.gitignore +++ b/.gitignore @@ -141,6 +141,7 @@ dmypy.json docker/*.whl docker/root/*.whl docker/root/defaults/examples +docker/testing/volumes .local/ diff --git a/Makefile b/Makefile index f61f8b34..30ca26b3 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,9 @@ docker_stage: wheel docker: docker_stage sudo docker build --progress=plain --no-cache -t ytdl-sub:local docker/ docker_ubuntu: docker_stage - sudo docker build --progress=plain --no-cache -t ytdl-sub:local_ubuntu -f docker/Dockerfile.ubuntu docker/ + sudo docker build --progress=plain --no-cache -t ytdl-sub-ubuntu:local -f docker/Dockerfile.ubuntu docker/ +docker_gui: docker_stage + sudo docker build --progress=plain --no-cache -t ytdl-sub-gui:local -f docker/Dockerfile.gui docker/ executable: clean pyinstaller ytdl-sub.spec mv dist/ytdl-sub dist/ytdl-sub${EXEC_SUFFIX} diff --git a/docker/Dockerfile.gui b/docker/Dockerfile.gui new file mode 100644 index 00000000..a057dbdc --- /dev/null +++ b/docker/Dockerfile.gui @@ -0,0 +1,85 @@ +FROM lscr.io/linuxserver/code-server:4.18.0 + +# Needed for phantomjs +ENV OPENSSL_CONF=/etc/ssl + +############################################################################### +# YTDL-SUB INSTALL + +SHELL ["/bin/bash", "-c"] +COPY root/ / +RUN mkdir -p /config && \ + apt-get -y update && \ + apt-get -y upgrade && \ + apt-get install --no-install-recommends -y \ + software-properties-common && \ + apt-get -y update && \ + apt-get -y upgrade && \ + apt-get install --no-install-recommends -y \ + vim \ + g++ \ + nano \ + make \ + python3.10-dev \ + python3-pip \ + fontconfig \ + xz-utils \ + bzip2 \ + aria2 \ + python3-venv && \ + if [[ $(uname -m) == "x86_64" ]]; then \ + curl -L -o ffmpeg.tar.gz https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz && \ + tar -xf ffmpeg.tar.gz && \ + chmod +x ffmpeg-master-latest-linux64-gpl/bin/ffmpeg && \ + chmod +x ffmpeg-master-latest-linux64-gpl/bin/ffprobe && \ + mv ffmpeg-master-latest-linux64-gpl/bin/ffmpeg /usr/bin/ffmpeg && \ + mv ffmpeg-master-latest-linux64-gpl/bin/ffprobe /usr/bin/ffprobe && \ + rm ffmpeg.tar.gz && \ + rm -rf ffmpeg-master-latest-linux64-gpl/ ; \ + else \ + curl -L -o ffmpeg.tar.gz https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz && \ + tar -xf ffmpeg.tar.gz && \ + chmod +x ffmpeg-master-latest-linuxarm64-gpl/bin/ffmpeg && \ + chmod +x ffmpeg-master-latest-linuxarm64-gpl/bin/ffprobe && \ + mv ffmpeg-master-latest-linuxarm64-gpl/bin/ffmpeg /usr/bin/ffmpeg && \ + mv ffmpeg-master-latest-linuxarm64-gpl/bin/ffprobe /usr/bin/ffprobe && \ + rm ffmpeg.tar.gz && \ + rm -rf ffmpeg-master-latest-linuxarm64-gpl/ ; \ + fi && \ + # Ensure ffmpeg is installed + ffmpeg -version && \ + # Install phantomjs if using x86_64, ensure it is properly installed + if [[ $(uname -m) == "x86_64" ]]; then \ + curl -L -o phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && \ + tar -xvf phantomjs.tar.bz2 && \ + mv phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs && \ + rm -rf phantomjs-2.1.1-linux-x86_64/ && \ + rm phantomjs.tar.bz2 && \ + echo "Phantom JS version:" && \ + phantomjs --version ; \ + fi && \ + # Install ytdl-sub, ensure it is installed properly + pip install --no-cache-dir ytdl_sub-*.whl && \ + ytdl-sub -h && \ + # Delete unneeded packages after install + rm ytdl_sub-*.whl && \ + apt-get remove -y \ + g++ \ + make \ + xz-utils \ + bzip2 \ + python3.10-dev \ + python3-venv && \ + apt-get autoremove -y && \ + apt-get purge -y --auto-remove && \ + rm -rf /var/lib/apt/lists/* + +############################################################################### +# CONTAINER CONFIGS + +ENV EDITOR="nano" \ +HOME="/config" \ +DOCKER_MODS=linuxserver/mods:universal-cron \ +DEFAULT_WORKSPACE=/config/ytdl-sub-configs + +VOLUME /config \ No newline at end of file diff --git a/docker/root/etc/cont-init.d/30-config b/docker/root/etc/cont-init.d/30-config index ed02409a..929e9add 100644 --- a/docker/root/etc/cont-init.d/30-config +++ b/docker/root/etc/cont-init.d/30-config @@ -1,12 +1,15 @@ #!/usr/bin/with-contenv bash # copy config -[[ ! -e /config/config.yaml ]] && \ - cp /defaults/config.yaml /config/config.yaml -[[ ! -e /config/subscriptions.yaml ]] && \ - cp /defaults/subscriptions.yaml /config/subscriptions.yaml -[[ ! -d /config/examples ]] && \ - cp -R /defaults/examples /config/ +[[ ! -e /config/ytdl-sub-configs/config.yaml ]] && \ + mkdir -p /config/ytdl-sub-configs && \ + cp /defaults/config.yaml /config/ytdl-sub-configs/config.yaml +[[ ! -e /config/ytdl-sub-configs/subscriptions.yaml ]] && \ + mkdir -p /config/ytdl-sub-configs && \ + cp /defaults/subscriptions.yaml /config/ytdl-sub-configs/subscriptions.yaml +[[ ! -d /config/ytdl-sub-configs/examples ]] && \ + mkdir -p /config/ytdl-sub-configs/examples && \ + cp /defaults/examples/* /config/ytdl-sub-configs/examples # permissions chown -R ${PUID:-abc}:${PGID:-abc} \ diff --git a/docker/testing/docker-compose.yml b/docker/testing/docker-compose.yml new file mode 100644 index 00000000..1a8797b9 --- /dev/null +++ b/docker/testing/docker-compose.yml @@ -0,0 +1,13 @@ +services: + ytdl-sub-gui: + image: ytdl-sub-gui:local + container_name: ytdl-sub-gui + environment: + - PUID=1000 + - PGID=1000 + - TZ=America/Los_Angeles + volumes: + - ./volumes/ytdl-sub-gui:/config + ports: + - 8443:8443 + restart: unless-stopped diff --git a/src/ytdl_sub/__init__.py b/src/ytdl_sub/__init__.py index 94aae306..add5bcfb 100644 --- a/src/ytdl_sub/__init__.py +++ b/src/ytdl_sub/__init__.py @@ -1,2 +1,2 @@ -__pypi_version__ = "2023.03.24.post7" -__local_version__ = "2023.03.24+14e4a4b" +__pypi_version__ = "2023.10.22" +__local_version__ = "2023.10.22+8a02a40"