diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3366092 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +db +appdata +audio +video +subscriptions +users \ No newline at end of file diff --git a/.gitignore b/.gitignore index 44fa9c2..e0af431 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,11 @@ backend/users/* backend/appdata/cookies.txt backend/public src/assets/i18n/*.json + +# User Files +db/ +appdata/ +audio/ +video/ +subscriptions/ +users/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ead755e..0452eed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,8 @@ +FROM alpine:latest AS ffmpeg + +COPY docker-build.sh . +RUN sh ./docker-build.sh + FROM alpine:latest as frontend RUN apk add --no-cache \ @@ -26,7 +31,6 @@ ENV NO_UPDATE_NOTIFIER=true RUN addgroup -S $USER -g $GID && adduser -D -S $USER -G $USER -u $UID RUN apk add --no-cache \ - ffmpeg \ npm \ python2 \ python3 \ @@ -35,6 +39,8 @@ RUN apk add --no-cache \ atomicparsley WORKDIR /app +COPY --from=ffmpeg /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg +COPY --from=ffmpeg /usr/local/bin/ffprobe /usr/local/bin/ffprobe COPY --chown=$UID:$GID [ "backend/package.json", "backend/package-lock.json", "/app/" ] ENV PM2_HOME=/app/pm2 RUN npm install pm2 -g diff --git a/docker-build.sh b/docker-build.sh new file mode 100644 index 0000000..5876372 --- /dev/null +++ b/docker-build.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# THANK YOU TALULAH (https://github.com/nottalulah) for your help in figuring this out +# and also optimizing some code with this commit. +# xoxo :D + +set -xeuo pipefail + +case $(uname -m) in + x86_64) + ARCH=amd64;; + aarch64) + ARCH=arm64;; + armhf) + ARCH=armhf;; + armv7) + ARCH=armel;; + armv7l) + ARCH=armel;; + *) + echo "Unsupported architecture: $(uname -m)" + exit 1 +esac + +echo "Architecture: $ARCH" +wget "https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-${ARCH}-static.tar.xz" -O ffmpeg.txz +mkdir /tmp/ffmpeg +tar xf ffmpeg.txz -C /tmp/ffmpeg +cp /tmp/ffmpeg/*/ffmpeg /usr/local/bin/ffmpeg +cp /tmp/ffmpeg/*/ffprobe /usr/local/bin/ffprobe +rm -rf /tmp/ffmpeg ffmpeg.txz \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 2d0d73e..60aef89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,8 @@ services: ytdl_use_local_db: 'false' write_ytdl_config: 'true' restart: always + depends_on: + - ytdl-mongo-db volumes: - ./appdata:/app/appdata - ./audio:/app/audio @@ -23,5 +25,6 @@ services: logging: driver: "none" container_name: mongo-db + restart: always volumes: - ./db/:/data/db \ No newline at end of file