Spaces:
Running
Running
zach
commited on
Commit
·
af7f823
1
Parent(s):
05a8882
Update Docker file and add more descriptive comments
Browse files- Dockerfile +30 -13
Dockerfile
CHANGED
@@ -1,24 +1,41 @@
|
|
1 |
-
# Use the official Python 3.11 slim image as the base
|
2 |
FROM python:3.11-slim
|
3 |
|
4 |
-
# Install
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Set the working directory in the container
|
10 |
WORKDIR /app
|
11 |
|
12 |
-
# Copy
|
13 |
-
|
|
|
14 |
|
15 |
-
#
|
16 |
-
#
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
#
|
|
|
|
|
20 |
EXPOSE 7860
|
21 |
|
22 |
-
# Define the command to
|
23 |
-
# uv run
|
24 |
-
|
|
|
|
1 |
+
# Use the official lightweight Python 3.11 slim image as the base
|
2 |
FROM python:3.11-slim
|
3 |
|
4 |
+
# Install uv using its standalone installer
|
5 |
+
# - `apt-get update` fetches the latest package lists
|
6 |
+
# - `apt-get install -y --no-install-recommends curl` installs curl to fetch the uv installer
|
7 |
+
# - `curl -LsSf` downloads and runs the uv installer script
|
8 |
+
# - `apt-get remove -y curl` removes curl after installation to save space
|
9 |
+
# - `apt-get clean && rm -rf /var/lib/apt/lists/*` removes cached package lists to reduce image size
|
10 |
+
RUN apt-get update && apt-get install -y --no-install-recommends curl && \
|
11 |
curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
12 |
+
apt-get remove -y curl && \
|
13 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
14 |
+
|
15 |
+
# Add uv to the system PATH so it can be run globally
|
16 |
+
ENV PATH="/root/.local/bin:$PATH"
|
17 |
|
18 |
# Set the working directory in the container
|
19 |
WORKDIR /app
|
20 |
|
21 |
+
# Copy dependency files first (pyproject.toml & uv.lock) to leverage Docker’s build cache
|
22 |
+
# - Ensures that if only the application code changes, dependencies do not need to be reinstalled
|
23 |
+
COPY pyproject.toml uv.lock /app/
|
24 |
|
25 |
+
# Install dependencies using uv
|
26 |
+
# - Reads pyproject.toml (and uv.lock, if available) to install dependencies
|
27 |
+
# - Creates a .venv in the project directory with all required packages
|
28 |
+
RUN uv sync
|
29 |
+
|
30 |
+
# Copy the remaining project files into the container
|
31 |
+
COPY . .
|
32 |
|
33 |
+
# Document the port used by Gradio (optional)
|
34 |
+
# - This does not actually expose the port, it is just metadata for users
|
35 |
+
# - To actually expose the port, use `docker run -p 7860:7860 <image>`
|
36 |
EXPOSE 7860
|
37 |
|
38 |
+
# Define the command to start the application
|
39 |
+
# - `uv run` ensures that the virtual environment is activated and dependencies are up to date
|
40 |
+
# - `python -m src.app` runs the main application module
|
41 |
+
CMD ["uv", "run", "python", "-m", "src.app"]
|