FROM python:3.11.9-slim-bookworm # avoid creating unnecessary .pyc, buffers, and pip caches ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 ENV PIP_NO_CACHE_DIR=1 ENV PIP_DISABLE_PIP_VERSION_CHECK=1 # install curl and certificates needed to install uv RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates git \ && rm -rf /var/lib/apt/lists/* # create a non-root user for added security RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /cardioTrack # install uv as user RUN curl -LsSf https://astral.sh/uv/install.sh | sh # copy the project files and do uv sync COPY --chown=user pyproject.toml uv.lock ./ RUN uv sync --locked --no-install-project # copy the rest of the files needed for inference COPY --chown=user . . RUN sed -i 's/\r$//' predicting_outcomes_in_heart_failure/app/entrypoint.sh \ && chmod +x predicting_outcomes_in_heart_failure/app/entrypoint.sh EXPOSE 7860 ENTRYPOINT ["predicting_outcomes_in_heart_failure/app/entrypoint.sh"] CMD ["uv", "run", "uvicorn", "predicting_outcomes_in_heart_failure.app.main:app", "--host", "0.0.0.0", "--port", "7860"]