Spaces:
Sleeping
Sleeping
Devang1290 commited on
Commit ·
a921d56
1
Parent(s): 5ef9cdf
fix: install deps as root before switching to non-root user
Browse files- Dockerfile +11 -13
Dockerfile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# Use a lightweight python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# Install required system packages
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
ffmpeg \
|
| 7 |
espeak-ng \
|
|
@@ -12,23 +12,21 @@ RUN apt-get update && apt-get install -y \
|
|
| 12 |
# Install uv for blazing-fast pip installs
|
| 13 |
RUN pip install uv
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
USER user
|
| 18 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
| 19 |
-
|
| 20 |
-
# Set working directory
|
| 21 |
-
WORKDIR /app
|
| 22 |
-
|
| 23 |
-
# Copy requirements first for better Docker layer caching
|
| 24 |
-
COPY --chown=user:user requirements-ci-english.txt requirements-ci-hindi.txt ./
|
| 25 |
|
| 26 |
-
# Install Python
|
| 27 |
RUN uv pip install --system --no-cache fastapi uvicorn pydantic
|
| 28 |
RUN uv pip install --system --no-cache -r requirements-ci-english.txt
|
| 29 |
RUN uv pip install --system --no-cache -r requirements-ci-hindi.txt
|
| 30 |
|
| 31 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
COPY --chown=user:user . /app
|
| 33 |
|
| 34 |
# Hugging Face Spaces routes traffic to port 7860
|
|
|
|
| 1 |
# Use a lightweight python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Install required system packages (as root)
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
ffmpeg \
|
| 7 |
espeak-ng \
|
|
|
|
| 12 |
# Install uv for blazing-fast pip installs
|
| 13 |
RUN pip install uv
|
| 14 |
|
| 15 |
+
# Copy requirements first for Docker layer caching
|
| 16 |
+
COPY requirements-ci-english.txt requirements-ci-hindi.txt ./
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
# Install ALL Python deps as root (before switching user)
|
| 19 |
RUN uv pip install --system --no-cache fastapi uvicorn pydantic
|
| 20 |
RUN uv pip install --system --no-cache -r requirements-ci-english.txt
|
| 21 |
RUN uv pip install --system --no-cache -r requirements-ci-hindi.txt
|
| 22 |
|
| 23 |
+
# Now create non-root user (HF Spaces requirement)
|
| 24 |
+
RUN useradd -m -u 1000 user
|
| 25 |
+
USER user
|
| 26 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 27 |
+
|
| 28 |
+
# Set working directory and copy project
|
| 29 |
+
WORKDIR /app
|
| 30 |
COPY --chown=user:user . /app
|
| 31 |
|
| 32 |
# Hugging Face Spaces routes traffic to port 7860
|