Skip to content

Commit

Permalink
try faster builds
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicTheDev committed Dec 15, 2024
1 parent d3290c0 commit ba0235b
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions Dockerfile
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"]

0 comments on commit ba0235b

Please sign in to comment.