From 09f3078f2b554aaff79f06e1872a37d46045b9ad Mon Sep 17 00:00:00 2001 From: swve Date: Tue, 18 Feb 2025 20:42:39 +0100 Subject: [PATCH] refactor: update API Dockerfile to use uv for dependency management --- apps/api/Dockerfile | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index cf9e2aba..f4625451 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -1,30 +1,13 @@ -# Use an official Python runtime as a parent image -FROM python:3.12.3-slim +FROM python:3.12-slim-bookworm +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ -# Set environment variables -ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 \ - PIP_NO_CACHE_DIR=off \ - PIP_DISABLE_PIP_VERSION_CHECK=on +# Copy the project into the image +ADD . /app -# Set work directory -WORKDIR /usr/learnhouse-api +# Sync the project into a new environment, using the frozen lockfile +WORKDIR /app +RUN uv sync --frozen -# Install system dependencies and Poetry -RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc \ - build-essential \ - && rm -rf /var/lib/apt/lists/* \ - && pip install --no-cache-dir uv - -# Copy only requirements to cache them in docker layer -COPY uv.lock pyproject.toml ./ - -# Install dependencies using uv -RUN uv sync - -# Copy the current directory contents into the container -COPY . . # Run the application -CMD ["python", "app.py"] \ No newline at end of file +CMD ["uv", "run", "app.py"] \ No newline at end of file