MAS-AI-0000 commited on
Commit
f0d0200
·
verified ·
1 Parent(s): e1e389d

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -0
Dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Python base (slim to keep image small)
2
+ FROM python:3.12-slim
3
+
4
+ # ---- system deps (for pydub/ffmpeg + soundfile) ----
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ ffmpeg \
7
+ libsndfile1 \
8
+ git \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # Create and switch to a non-root user
12
+ RUN useradd -m -u 1000 user
13
+ USER user
14
+ ENV PATH="/home/user/.local/bin:$PATH"
15
+
16
+ # Working directory inside the container
17
+ WORKDIR /app
18
+
19
+ # Copy requirements first (better cache)
20
+ COPY --chown=user ./requirements.txt requirements.txt
21
+
22
+ # Upgrade pip and install deps
23
+ RUN python -m pip install --no-cache-dir --upgrade pip \
24
+ && pip install --no-cache-dir -r requirements.txt
25
+
26
+ # Optional: pre-download NLTK resource used by the app
27
+ # (avoids downloading at runtime in a locked-down environment)
28
+ RUN python - <<'PY'
29
+ import nltk
30
+ try:
31
+ nltk.download("punkt_tab")
32
+ except Exception as e:
33
+ print("NLTK download warning:", e)
34
+ PY
35
+
36
+ # Copy app code
37
+ COPY --chown=user . /app
38
+
39
+ # Expose the default Spaces port
40
+ EXPOSE 7860
41
+
42
+ # Run FastAPI server (Spaces sets $PORT, default to 7860)
43
+ CMD ["bash", "-lc", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}"]