Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +20 -15
Dockerfile
CHANGED
|
@@ -3,30 +3,35 @@
|
|
| 3 |
# 1. Base Image
|
| 4 |
FROM python:3.12-slim
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
RUN useradd -m -u 1000 user
|
| 7 |
USER user
|
| 8 |
ENV HOME=/home/user
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
COPY --chown=user:user . .
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
# 2. Set Environment Variables
|
| 14 |
# PYTHONDONTWRITEBYTECODE: Prevents Python from writing .pyc files to disc (equivalent to python -B)
|
| 15 |
# PYTHONUNBUFFERED: Prevents Python from buffering stdin/stdout/stderr (equivalent to python -u)
|
| 16 |
ENV PYTHONDONTWRITEBYTECODE 1
|
| 17 |
ENV PYTHONUNBUFFERED 1
|
| 18 |
-
ENV HF_HOME=/home/user/app/hf_home/
|
| 19 |
-
|
| 20 |
-
# 3. Install system dependencies (git) and uv (Python package manager)
|
| 21 |
-
RUN apt-get update && \
|
| 22 |
-
apt-get install -y build-essential cmake && \
|
| 23 |
-
apt-get install -y --no-install-recommends git && \
|
| 24 |
-
pip install --no-cache-dir uv && \
|
| 25 |
-
apt-get clean && \
|
| 26 |
-
rm -rf /var/lib/apt/lists/*
|
| 27 |
-
|
| 28 |
-
# 4. Set working directory
|
| 29 |
-
WORKDIR /home/user/app
|
| 30 |
|
| 31 |
# 5. Clone the repository
|
| 32 |
# Cloning into the current directory (/app)
|
|
@@ -35,7 +40,7 @@ RUN git clone https://github.com/keshan/mcp_hackathon.git .
|
|
| 35 |
# 6. Install Python dependencies using uv
|
| 36 |
# uv sync will read pyproject.toml and install dependencies.
|
| 37 |
# It will create and use a virtual environment in .venv by default.
|
| 38 |
-
RUN uv sync
|
| 39 |
|
| 40 |
# 7. Expose the port Gradio runs on (default is 7860)
|
| 41 |
EXPOSE 7860
|
|
|
|
| 3 |
# 1. Base Image
|
| 4 |
FROM python:3.12-slim
|
| 5 |
|
| 6 |
+
# 3. Install system dependencies (git) and uv (Python package manager)
|
| 7 |
+
RUN apt-get update && \
|
| 8 |
+
apt-get install -y build-essential cmake && \
|
| 9 |
+
apt-get install -y --no-install-recommends git && \
|
| 10 |
+
pip install --no-cache-dir uv && \
|
| 11 |
+
apt-get clean && \
|
| 12 |
+
rm -rf /var/lib/apt/lists/*
|
| 13 |
+
|
| 14 |
+
# Create non-root user
|
| 15 |
RUN useradd -m -u 1000 user
|
| 16 |
USER user
|
| 17 |
ENV HOME=/home/user
|
| 18 |
+
|
| 19 |
+
# Set uv cache location
|
| 20 |
+
ENV UV_CACHE_DIR="${HOME}/.cache/uv"
|
| 21 |
+
RUN mkdir -p "${UV_CACHE_DIR}"
|
| 22 |
+
|
| 23 |
+
# Use app directory
|
| 24 |
+
WORKDIR /home/user/app
|
| 25 |
COPY --chown=user:user . .
|
| 26 |
|
| 27 |
+
# Install uv and run sync
|
| 28 |
+
RUN pip install --no-cache-dir uv
|
| 29 |
+
|
| 30 |
# 2. Set Environment Variables
|
| 31 |
# PYTHONDONTWRITEBYTECODE: Prevents Python from writing .pyc files to disc (equivalent to python -B)
|
| 32 |
# PYTHONUNBUFFERED: Prevents Python from buffering stdin/stdout/stderr (equivalent to python -u)
|
| 33 |
ENV PYTHONDONTWRITEBYTECODE 1
|
| 34 |
ENV PYTHONUNBUFFERED 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# 5. Clone the repository
|
| 37 |
# Cloning into the current directory (/app)
|
|
|
|
| 40 |
# 6. Install Python dependencies using uv
|
| 41 |
# uv sync will read pyproject.toml and install dependencies.
|
| 42 |
# It will create and use a virtual environment in .venv by default.
|
| 43 |
+
RUN uv sync && rm -rf "${UV_CACHE_DIR}/git-v0"
|
| 44 |
|
| 45 |
# 7. Expose the port Gradio runs on (default is 7860)
|
| 46 |
EXPOSE 7860
|