Update Dockerfile
Browse files- Dockerfile +18 -14
Dockerfile
CHANGED
|
@@ -1,33 +1,37 @@
|
|
| 1 |
-
# Use Python 3.13.2
|
| 2 |
FROM python:3.13.2-slim
|
| 3 |
|
| 4 |
-
# Install system dependencies
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
-
|
|
|
|
| 7 |
curl \
|
|
|
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
# Install uv
|
| 11 |
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
# Set
|
| 17 |
-
ENV
|
| 18 |
-
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# Install Python dependencies using uv
|
| 24 |
RUN uv sync --frozen --no-dev
|
| 25 |
|
| 26 |
-
# Copy application
|
| 27 |
-
COPY
|
| 28 |
|
| 29 |
-
# Create directories that might be needed
|
| 30 |
-
RUN mkdir -p notebooks
|
| 31 |
|
| 32 |
# Expose the port that Gradio will run on
|
| 33 |
EXPOSE 7860
|
|
|
|
| 1 |
+
# Use Python 3.13.2 as the base image
|
| 2 |
FROM python:3.13.2-slim
|
| 3 |
|
| 4 |
+
# Install system dependencies as root first
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
+
gcc \
|
| 7 |
+
g++ \
|
| 8 |
curl \
|
| 9 |
+
build-essential \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
# Install uv
|
| 13 |
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
| 14 |
|
| 15 |
+
# Create user after system packages are installed
|
| 16 |
+
RUN useradd -m -u 1000 user
|
| 17 |
+
USER user
|
| 18 |
|
| 19 |
+
# Set home to the user's home directory
|
| 20 |
+
ENV HOME=/home/user \
|
| 21 |
+
PATH=/home/user/.local/bin:$PATH
|
| 22 |
|
| 23 |
+
# Set the working directory
|
| 24 |
+
WORKDIR $HOME/app
|
| 25 |
+
|
| 26 |
+
# Copy pyproject.toml and uv.lock first to leverage Docker cache
|
| 27 |
+
COPY --chown=user:user pyproject.toml uv.lock ./
|
| 28 |
|
| 29 |
# Install Python dependencies using uv
|
| 30 |
RUN uv sync --frozen --no-dev
|
| 31 |
|
| 32 |
+
# Copy the application code
|
| 33 |
+
COPY --chown=user:user . $HOME/app
|
| 34 |
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# Expose the port that Gradio will run on
|
| 37 |
EXPOSE 7860
|