Sanket17 commited on
Commit
2bff7a4
Β·
1 Parent(s): 30b0f5b

fix: lighter base image, faster build

Browse files
Files changed (3) hide show
  1. .huggingface/build.yml +3 -0
  2. Dockerfile +8 -1
  3. app.py +7 -22
.huggingface/build.yml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # .huggingface/build.yml
2
+ build:
3
+ dockerfile: Dockerfile
Dockerfile CHANGED
@@ -1,15 +1,22 @@
1
- FROM mcr.microsoft.com/playwright/python:v1.44.0-jammy
2
 
3
  WORKDIR /app
4
 
 
 
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  ffmpeg \
 
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
  COPY requirements.txt .
10
  RUN pip install --no-cache-dir --upgrade pip && \
11
  pip install --no-cache-dir -r requirements.txt
12
 
 
 
 
 
13
  COPY . .
14
 
15
  RUN mkdir -p /tmp/bytebrain-output
 
1
+ FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
  ffmpeg \
9
+ curl \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
  COPY requirements.txt .
13
  RUN pip install --no-cache-dir --upgrade pip && \
14
  pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Install playwright + chromium in one step with progress
17
+ RUN playwright install-deps chromium && \
18
+ playwright install chromium
19
+
20
  COPY . .
21
 
22
  RUN mkdir -p /tmp/bytebrain-output
app.py CHANGED
@@ -1,9 +1,3 @@
1
- """
2
- app.py
3
- ------
4
- Gradio UI wrapper around run_pipeline.py.
5
- Fixes Windows cp1252 UnicodeEncodeError by forcing UTF-8 in the subprocess.
6
- """
7
 
8
  import os
9
  import sys
@@ -13,18 +7,12 @@ import logging
13
  from pathlib import Path
14
  from datetime import datetime
15
  import gradio as gr
16
- from dotenv import load_dotenv
17
- load_dotenv()
18
- from openai import OpenAI
19
- openai = OpenAI(
20
- api_key=os.getenv("OPENAI_API_KEY"),
21
- )
22
- # ── Logging setup ─────────────────────────────────────────────────────────────
23
  # ── Logging setup ─────────────────────────────────────────────────────────────
24
  logging.basicConfig(
25
  level=logging.INFO,
26
  format="%(asctime)s [%(levelname)s] %(message)s",
27
- handlers=[logging.StreamHandler(sys.stdout)] # HF Spaces captures stdout
28
  )
29
  log = logging.getLogger(__name__)
30
 
@@ -56,7 +44,7 @@ def generate_video(topic: str):
56
 
57
  log.info(f"Output path: {output_video}")
58
 
59
- env = os.environ.copy()
60
  env["PIPELINE_OUTPUT_DIR"] = str(output_root)
61
  env["PYTHONIOENCODING"] = "utf-8"
62
  env["PYTHONUTF8"] = "1"
@@ -84,7 +72,7 @@ def generate_video(topic: str):
84
 
85
  log.info(f"Pipeline exited with code: {proc.returncode}")
86
  if proc.stdout:
87
- log.info(f"STDOUT:\n{proc.stdout[-2000:]}") # last 2000 chars
88
  if proc.stderr:
89
  log.warning(f"STDERR:\n{proc.stderr[-2000:]}")
90
 
@@ -125,12 +113,9 @@ with gr.Blocks(title="ByteBrain Video Generator") as demo:
125
  log.info("Gradio UI built successfully.")
126
 
127
  if __name__ == "__main__":
128
- # HF Spaces: server_name must be "0.0.0.0", port 7860
129
- # Do NOT use share=True β€” HF handles tunneling itself
130
-
131
-
132
  demo.queue().launch(
133
- server_name="0.0.0.0", # required for HF Spaces
134
- server_port=7860, # required for HF Spaces
135
  show_error=True,
 
136
  )
 
 
 
 
 
 
 
1
 
2
  import os
3
  import sys
 
7
  from pathlib import Path
8
  from datetime import datetime
9
  import gradio as gr
10
+
 
 
 
 
 
 
11
  # ── Logging setup ─────────────────────────────────────────────────────────────
12
  logging.basicConfig(
13
  level=logging.INFO,
14
  format="%(asctime)s [%(levelname)s] %(message)s",
15
+ handlers=[logging.StreamHandler(sys.stdout)]
16
  )
17
  log = logging.getLogger(__name__)
18
 
 
44
 
45
  log.info(f"Output path: {output_video}")
46
 
47
+ env = os.environ.copy() # passes all HF Secrets automatically
48
  env["PIPELINE_OUTPUT_DIR"] = str(output_root)
49
  env["PYTHONIOENCODING"] = "utf-8"
50
  env["PYTHONUTF8"] = "1"
 
72
 
73
  log.info(f"Pipeline exited with code: {proc.returncode}")
74
  if proc.stdout:
75
+ log.info(f"STDOUT:\n{proc.stdout[-2000:]}")
76
  if proc.stderr:
77
  log.warning(f"STDERR:\n{proc.stderr[-2000:]}")
78
 
 
113
  log.info("Gradio UI built successfully.")
114
 
115
  if __name__ == "__main__":
 
 
 
 
116
  demo.queue().launch(
117
+ server_name="0.0.0.0",
118
+ server_port=7860,
119
  show_error=True,
120
+ ssr_mode=False,
121
  )