From 13156ae5803cfdb3610b10fa811948ccd13fa511 Mon Sep 17 00:00:00 2001 From: Eir Sunny Date: Wed, 18 Dec 2024 16:24:21 -0600 Subject: [PATCH] Initial commit --- .dockerignore | 4 ++ .gitignore | 7 ++++ Dockerfile-eirtube | 23 +++++++++++ Dockerfile-eirtube-nvidia | 37 ++++++++++++++++++ Dockerfile-newleaf | 28 ++++++++++++++ README.md | 18 ++++++++- docker-compose.yml | 80 +++++++++++++++++++++++++++++++++++++++ eirtube-start.sh | 16 ++++++++ newleaf-start.sh | 10 +++++ restart-vpn.sh | 20 ++++++++++ 10 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100755 Dockerfile-eirtube create mode 100755 Dockerfile-eirtube-nvidia create mode 100755 Dockerfile-newleaf create mode 100644 docker-compose.yml create mode 100755 eirtube-start.sh create mode 100755 newleaf-start.sh create mode 100755 restart-vpn.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c232ec3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +restart-vpn.sh + +eirtube/cache/* +eirtube/logs/* diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96df19b --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +eirtube/ +eirtube-binaries/ +newleaf/ +phantomjs/ +vpn/ +.htpasswd +restartvpn.log diff --git a/Dockerfile-eirtube b/Dockerfile-eirtube new file mode 100755 index 0000000..1673d0e --- /dev/null +++ b/Dockerfile-eirtube @@ -0,0 +1,23 @@ +FROM python:3.12-alpine + +# Eirtube stuff +RUN apt-get install -y \ + bash \ + #ffmpeg \ + #yt-dlp \ + npm \ + git \ + tar \ + coreutils + +COPY eirtube-binaries/* /usr/bin + +# Set up node packages +RUN rm -rf /tmp && mkdir /tmp +COPY eirtube/package*.* /tmp +RUN bash -c "cd /tmp && npm install --legacy-peer-deps --loglevel verbose" + +COPY eirtube-start.sh . + +EXPOSE 10412 +CMD ./eirtube-start.sh diff --git a/Dockerfile-eirtube-nvidia b/Dockerfile-eirtube-nvidia new file mode 100755 index 0000000..005331b --- /dev/null +++ b/Dockerfile-eirtube-nvidia @@ -0,0 +1,37 @@ +#FROM python:3.12-alpine +FROM node:22-slim + +RUN apt-get update + +# Nvidia stuff +RUN apt-get install -y \ + software-properties-common \ + curl +RUN curl https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb -o /tmp/cuda-keyring.deb +RUN dpkg -i /tmp/cuda-keyring.deb +RUN add-apt-repository contrib +RUN apt-get install -Vy cuda-drivers +#RUN apt-get install nvidia-driver-assistant +#RUN nvidia-driver-assistant --install + +# Eirtube stuff +RUN apt-get install -y \ + bash \ + #ffmpeg \ + #yt-dlp \ + npm \ + git \ + tar \ + coreutils + +COPY eirtube-binaries/* /usr/bin + +# Set up node packages +RUN rm -rf /tmp && mkdir /tmp +COPY eirtube/package*.* /tmp +RUN bash -c "cd /tmp && npm install --legacy-peer-deps --loglevel verbose" + +COPY eirtube-start.sh . + +EXPOSE 10412 +CMD ./eirtube-start.sh diff --git a/Dockerfile-newleaf b/Dockerfile-newleaf new file mode 100755 index 0000000..a9fa5ed --- /dev/null +++ b/Dockerfile-newleaf @@ -0,0 +1,28 @@ +FROM python:3.11.9-alpine3.19 + +RUN apk del .python-rundeps +RUN apk add --no-cache \ + bash \ + ffmpeg \ + yt-dlp \ + nodejs \ + npm \ + git \ + curl \ + crystal shards \ + musl + +# Install PhantomJS +#RUN curl -k -Ls https://github.com/Nuxify/phantomized/releases/download/2.1.1/dockerized-phantomjs.tar.gz | tar -xzf - +#RUN cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs +COPY phantomjs/bin/phantomjs /usr/local/bin/phantomjs + +COPY newleaf/requirements.txt . + +RUN pip install -r requirements.txt + +COPY newleaf-start.sh . + +EXPOSE 3000 + +CMD ./newleaf-start.sh diff --git a/README.md b/README.md index b660cf5..54eb51b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ # eirtube-stack-docker -The setup I use to run Eirtube and my Newleaf instance. \ No newline at end of file +This is the setup I use to run Eirtube and my Newleaf instance. + +## Installation + +1. Clone [EirTube](https://git.eir-nya.gay/eir/eirtube) and [my Newleaf instance](https://git.eir-nya.gay/eir/newleaf) to `eirtube` and `newleaf` respectively. + +2. Make a folder `eirtube-binaries`. Here you'll need to place the latest `yt-dlp` binary as well as `ffmpeg` and `ffprobe` taken from the latest Jellyfin-ffmpeg build for optimization. + +3. Get the latest version of `phantomjs` and extract it to `phantomjs` in this folder. + +4. Edit the docker-compose file. Set up the configuration for the `gluetun` container. You'll need your own vpn username and password to enter. Add a custom timezone for where you live. If you don't want to use the nvidia dockerfile, replace `dockerfile: ./Dockerfile-eirtube-nvidia` with `dockerfile: ./Dockerfile-eirtube` and remove `runtime: nvidia`, and `deploy:` and everything inside it. + +5. Use docker-compose to build and run the docker-compose file, using `docker compose build` and `docker compose up -d`. + +## License + +I know CloudTube and thus EirTube use the AGPL license. Some code from its Dockerfile is used here. Therefore, I used the same license. Both CloudTube and NewLeaf belong to [Cadence](https://cadence.moe/). diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a7098a7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,80 @@ +services: + ct-vpn: + image: qmcgaw/gluetun + container_name: ct-vpn + cap_add: + - NET_ADMIN + devices: + - /dev/net/tun:/dev/net/tun + ports: + - 3000:3000 + - 10412:10412 + - 127.0.0.1:8000:8000/tcp # Control server + volumes: + - ./vpn:/gluetun + environment: + # See https://github.com/qdm12/gluetun-wiki/tree/main/setup#setup + - VPN_SERVICE_PROVIDER=protonvpn + # - VPN_TYPE=wireguard + # OpenVPN: + # - OPENVPN_USER=... + # - OPENVPN_PASSWORD=... + # Wireguard: + # - WIREGUARD_PRIVATE_KEY=... + # - WIREGUARD_ADDRESSES=... + # Timezone for accurate log times + # - TZ=America/Chicago + # Server list updater + # See https://github.com/qdm12/gluetun-wiki/blob/main/setup/servers.md#update-the-vpn-servers-list + - UPDATER_PERIOD= + - SERVER_COUNTRIES=Netherlands + - VPN_PORT_FORWARDING=on + restart: "unless-stopped" + eirtube: + build: + context: . + dockerfile: ./Dockerfile-eirtube-nvidia + container_name: eirtube + environment: + - PUID=1000 + - PGID=1000 + - TZ=America/Chicago + volumes: + - ./eirtube:/live/eirtube + #ports: + #- 10412:10412 + restart: "unless-stopped" + network_mode: service:ct-vpn + depends_on: + - ct-vpn + #healthcheck: + #test: curl -f http://localhost:9092 || exit 1 + #interval: 5m00s + #timeout: 10s + #retries: 2 + runtime: nvidia + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] + newleaf: + build: + context: . + dockerfile: ./Dockerfile-newleaf + container_name: newleaf + environment: + - PUID=1000 + - PGID=1000 + # - TZ=America/Chicago + volumes: + - ./phantomjs:/live/phantomjs + - ./newleaf:/live/newleaf + #ports: + #- 3000:3000 + restart: "unless-stopped" + network_mode: service:ct-vpn + depends_on: + - ct-vpn diff --git a/eirtube-start.sh b/eirtube-start.sh new file mode 100755 index 0000000..b29d70c --- /dev/null +++ b/eirtube-start.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +printf "\033[38;5;154meirtube-start\033[0m\n" + +cd /live/eirtube + +#npm ci --legacy-peer-deps --loglevel verbose +#npm install sass@1.57.1 + +if [ ! -d "node_modules" ]; then + cp -r /tmp/node_modules . +fi +if [ ! -d "logs" ]; then + mkdir logs +fi +node --disable-warning DEP0040 server.js | tee logs/$(date +'%Y_%m_%d_%H-%M-%S').txt diff --git a/newleaf-start.sh b/newleaf-start.sh new file mode 100755 index 0000000..cacbd0e --- /dev/null +++ b/newleaf-start.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +cd /live/phantomjs +cp -R lib lib64 / +cp -R x86_64-linux-gnu /usr/lib +cp -R share /usr/share +cp -R fonts /etc + +cd /live/newleaf +python index.py diff --git a/restart-vpn.sh b/restart-vpn.sh new file mode 100755 index 0000000..b1431cf --- /dev/null +++ b/restart-vpn.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +echo "BEGIN $(date --rfc-3339=seconds)" 2>&1 | tee -a ./restartvpn.log + +curl -s -X GET "http://127.0.0.1:8000/v1/publicip/ip" 2>&1 | tee -a ./restartvpn.log # Print the original IP + +curl -s -X PUT -H "Content-Type: application/json" -d '{"status":"stopped"}' "http://127.0.0.1:8000/v1/openvpn/status" 2>&1 | tee -a ./restartvpn.log # Stop OpenVPN + +sleep 5 + +curl -s -X PUT -H "Content-Type: application/json" -d '{"status":"running"}' "http://127.0.0.1:8000/v1/openvpn/status" 2>&1 | tee -a ./restartvpn.log # Start OpenVPN (changing the server it's connecting to) + +sleep 5 + +curl -s -X GET "http://127.0.0.1:8000/v1/openvpn/status" 2>&1 | tee -a ./restartvpn.log # Print the Gluetun status + +curl -s -X GET "http://127.0.0.1:8000/v1/publicip/ip" 2>&1 | tee -a ./restartvpn.log # Print the new IP + +echo "END $(date --rfc-3339=seconds)" 2>&1 | tee -a ./restartvpn.log +