-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3290c0
commit ba0235b
Showing
1 changed file
with
10 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
# Base Python image | ||
FROM python:3.12-slim-bookworm AS base | ||
FROM python:3.11-slim-bookworm AS base | ||
|
||
# Builder stage | ||
FROM base AS builder | ||
# Install git, gcc, g++, and other necessary tools | ||
# Install build tools and libraries | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
gcc \ | ||
g++ \ | ||
libsnappy-dev \ | ||
build-essential \ | ||
python3-dev && \ | ||
python3-dev \ | ||
libsnappy-dev && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy uv binary directly from its prebuilt Docker image | ||
# Copy uv binary | ||
COPY --from=ghcr.io/astral-sh/uv:0.5.9 /uv /bin/uv | ||
|
||
# Enable bytecode compilation and use link mode as "copy" | ||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy | ||
|
||
WORKDIR /app | ||
|
||
# Create a virtual environment with uv | ||
# Create virtual environment | ||
RUN uv venv | ||
|
||
# Copy dependency files into the container | ||
# Copy dependency files | ||
COPY requirements.txt /app/ | ||
|
||
# Install dependencies using uv in a cached way | ||
# Install dependencies | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv pip install -r requirements.txt | ||
uv pip install --verbose -r requirements.txt | ||
|
||
# Copy the rest of the application code | ||
# Copy the rest of the application | ||
COPY . /app | ||
|
||
# Final runtime stage | ||
FROM base | ||
# Copy the built application from the builder stage | ||
COPY --from=builder /app /app | ||
# Add virtual environment's bin to PATH | ||
ENV PATH="/app/.venv/bin:$PATH" | ||
|
||
# Command to run the application | ||
CMD ["python3", "main.py"] |