-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (34 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
44 lines (34 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Stage 1: Build stage
FROM python:3.12-slim-bookworm AS builder
# Install uv
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Set the working directory
WORKDIR /app
# Copy your project files and lock file
# COPY requirements.txt .
# If using a pyproject.toml and uv lock, copy those instead
COPY pyproject.toml uv.lock ./
# Install dependencies using uv
RUN uv sync --frozen
# Stage 2: Runtime stage
FROM python:3.12-slim-bookworm
# Set the working directory
WORKDIR /app
# Copy the installed dependencies from the builder stage
COPY --from=builder /bin/uv /bin/uvx /bin/
# (above) Optional, if uv is needed at runtime
COPY --from=builder /app/.venv /app/.venv
# (above) Copy the virtual environment
# Add the virtual environment to PATH
ENV PATH="/app/.venv/bin:${PATH}"
# Copy your application code
COPY main.py api_runner.py ./
COPY api/ ./api/
COPY models/ ./models/
COPY schemas/ ./schemas/
COPY setting/ ./setting/
COPY static_data/ ./static_data/
COPY utilities/ ./utilities/
# Define the command to run your application
CMD ["uv", "run", "main.py", "--dev"]