# Use official Python base image FROM python:3.11-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ POETRY_VERSION=2.1.3 # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ curl build-essential libpq-dev gcc \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Install Poetry RUN curl -sSL https://install.python-poetry.org | python3 - && \ ln -s /root/.local/bin/poetry /usr/local/bin/poetry # Copy pyproject and poetry.lock to leverage Docker cache COPY pyproject.toml poetry.lock* /app/ # Configure Poetry to not create virtualenvs RUN poetry config virtualenvs.create false # Install dependencies RUN poetry install --no-interaction --no-ansi --no-root # Copy the rest of the application code COPY . /app # Expose the port FastAPI will run on EXPOSE 8000 # Start the FastAPI app using uvicorn CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]