Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Alina Lozovskaya
commited on
Commit
•
b91f2b7
1
Parent(s):
2620acf
Switch to uv in dev Dockerfile
Browse files- backend/Dockerfile.dev +22 -12
backend/Dockerfile.dev
CHANGED
@@ -1,25 +1,35 @@
|
|
1 |
-
|
|
|
2 |
|
|
|
3 |
WORKDIR /app
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Install required system dependencies
|
6 |
RUN apt-get update && apt-get install -y \
|
7 |
build-essential \
|
8 |
&& rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
-
poetry install --no-interaction --no-ansi --no-root
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
ENV LOG_LEVEL=INFO
|
23 |
|
24 |
# In dev, mount volume directly
|
25 |
-
CMD ["uvicorn", "app.asgi:app", "--host", "0.0.0.0", "--port", "7860", "--reload", "--log-level", "warning", "--no-access-log"]
|
|
|
1 |
+
# Use a Python image with uv pre-installed
|
2 |
+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
3 |
|
4 |
+
# Set the working directory
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Enable bytecode compilation
|
8 |
+
ENV UV_COMPILE_BYTECODE=1
|
9 |
+
|
10 |
+
# Copy from the cache instead of linking since it's a mounted volume
|
11 |
+
ENV UV_LINK_MODE=copy
|
12 |
+
|
13 |
+
# Environment variables configuration for logs
|
14 |
+
ENV PYTHONUNBUFFERED=1
|
15 |
+
ENV LOG_LEVEL=INFO
|
16 |
+
|
17 |
# Install required system dependencies
|
18 |
RUN apt-get update && apt-get install -y \
|
19 |
build-essential \
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
|
22 |
+
# Copy uv configuration files
|
23 |
+
COPY pyproject.toml uv.lock ./
|
24 |
|
25 |
+
# Install dependencies using uv
|
26 |
+
RUN uv sync --frozen --no-install-project --no-dev
|
27 |
|
28 |
+
# Place executables in the environment at the front of the path
|
29 |
+
ENV PATH="/app/.venv/bin:$PATH"
|
|
|
30 |
|
31 |
+
# Reset the entrypoint, don't invoke `uv`
|
32 |
+
ENTRYPOINT []
|
|
|
33 |
|
34 |
# In dev, mount volume directly
|
35 |
+
CMD ["uv" "run" "uvicorn", "app.asgi:app", "--host", "0.0.0.0", "--port", "7860", "--reload", "--log-level", "warning", "--no-access-log"]
|