diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0f3930b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.git +.agents +.codex +downloads +**/.venv +**/.venv_network_failed +**/__pycache__ +**/.pytest_cache +**/*.egg-info +**/*.py[cod] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4ffae9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +downloads/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8e941f3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM python:3.12-slim-bookworm + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PIP_NO_CACHE_DIR=1 + +RUN apt-get update \ + && apt-get install --yes --no-install-recommends \ + ca-certificates \ + ffmpeg \ + openssl \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY N_m3u8DL_py/pyproject.toml N_m3u8DL_py/ +COPY N_m3u8DL_py/src N_m3u8DL_py/src +COPY m3u8downloaderd/pyproject.toml m3u8downloaderd/ +COPY m3u8downloaderd/src m3u8downloaderd/src + +RUN python -m pip install --upgrade 'setuptools>=68' \ + && python -m pip install --no-build-isolation \ + /app/N_m3u8DL_py \ + /app/m3u8downloaderd + +RUN mkdir --parents /downloads + +EXPOSE 8000 + +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ + CMD python -c "from urllib.request import urlopen; urlopen('http://127.0.0.1:8000/api/bootstrap', timeout=3)" + +ENTRYPOINT ["python", "-m", "m3u8downloaderd"] +CMD ["--host", "0.0.0.0", "--port", "8000", "--download-root", "/downloads", "--max-active-downloads", "2"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..85bd32b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + m3u8downloaderd: + build: + context: . + dockerfile: Dockerfile + ports: + - "8123:8000" + volumes: + - /mnt/6THD/jellyfin-data/lost.found/keys:/downloads + restart: unless-stopped diff --git a/m3u8downloaderd/README.md b/m3u8downloaderd/README.md index ea58377..8edbf3f 100644 --- a/m3u8downloaderd/README.md +++ b/m3u8downloaderd/README.md @@ -3,6 +3,17 @@ `m3u8downloaderd` is an in-memory local-network web interface for the adjacent `N_m3u8DL_py` package. It requires Python 3.10+ and a system `ffmpeg`. +## Docker + +From the repository root, start the service and build its image when needed: + +```bash +docker-compose up +``` + +Open `http://127.0.0.1:8000`. Downloaded files are written to the repository's +`downloads/` directory. Use `docker-compose down` to stop the service. + Install both local packages into the same environment: ```bash