From 82d5c3c17348400ce2b5b95bbe966070fdd1a7b9 Mon Sep 17 00:00:00 2001 From: oimwiodev Date: Fri, 22 May 2026 20:24:58 +0100 Subject: [PATCH] Add Docker image support --- .dockerignore | 13 +++++++++++++ Dockerfile | 24 ++++++++++++++++++++++++ README.md | 25 +++++++++++++++++++++++++ docker-compose.yml | 15 +++++++++++++++ web_app.py | 4 +++- 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5a1353b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.cache/ +.git/ +.pytest_cache/ +.venv/ +__pycache__/ +logs/ +output/ +temp/ +*.log +*.mp3 +*.mp4 +*.pyc +*.wav diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aade7d5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.10-slim + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + GRADIO_SERVER_NAME=0.0.0.0 \ + PORT=7860 + +WORKDIR /app + +RUN apt-get update \ + && apt-get install -y --no-install-recommends ffmpeg ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir --upgrade pip \ + && pip install --no-cache-dir -r requirements.txt + +COPY . . + +RUN mkdir -p .cache temp output logs/gradio + +EXPOSE 7860 + +CMD ["python", "web_app.py"] diff --git a/README.md b/README.md index 0bea0ff..cbaebf9 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,31 @@ Gradio provides a local browser UI for starting dub jobs, watching logs, and dow Open `http://127.0.0.1:7860` and submit a YouTube URL. Jobs run through the same `main.py` pipeline, so the CLI options and environment variables still apply. +### Docker + +Build and run the Gradio UI in a container: + +```powershell +docker build -t youtube-auto-dub:gradio . +docker run --rm -p 7860:7860 ` + -e LM_STUDIO_BASE_URL=http://host.docker.internal:1234/v1 ` + -e LM_STUDIO_API_KEY=lm-studio ` + -e LM_STUDIO_MODEL=gemma-3-4b-it ` + -v ${PWD}\.cache:/app/.cache ` + -v ${PWD}\output:/app/output ` + -v ${PWD}\logs:/app/logs ` + -v ${PWD}\temp:/app/temp ` + youtube-auto-dub:gradio +``` + +Or use Compose: + +```powershell +docker compose up --build +``` + +When LM Studio runs on the host machine, use `http://host.docker.internal:1234/v1` from inside Docker instead of `http://127.0.0.1:1234/v1`. + Override the LM Studio endpoint or model from the CLI: ```powershell diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4ebc0e0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +services: + youtube-auto-dub: + build: . + image: youtube-auto-dub:gradio + ports: + - "7860:7860" + environment: + LM_STUDIO_BASE_URL: "http://host.docker.internal:1234/v1" + LM_STUDIO_API_KEY: "lm-studio" + LM_STUDIO_MODEL: "gemma-3-4b-it" + volumes: + - ./.cache:/app/.cache + - ./output:/app/output + - ./logs:/app/logs + - ./temp:/app/temp diff --git a/web_app.py b/web_app.py index 1fa1a65..1053bed 100644 --- a/web_app.py +++ b/web_app.py @@ -327,4 +327,6 @@ app = create_app() if __name__ == "__main__": - app.launch(server_name="127.0.0.1", server_port=7860) + server_name = os.getenv("GRADIO_SERVER_NAME", "127.0.0.1") + server_port = int(os.getenv("PORT", "7860")) + app.launch(server_name=server_name, server_port=server_port)