37 lines
798 B
Docker
37 lines
798 B
Docker
# Use official Python runtime as base image
|
|
FROM python:3.12-slim AS base
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
UV_PROJECT_ENVIRONMENT=/app/.venv
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install uv
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
|
|
|
# Copy dependency files
|
|
COPY pyproject.toml ./
|
|
|
|
# Install Python dependencies
|
|
RUN uv sync --no-dev
|
|
|
|
# Add virtual environment to PATH
|
|
ENV PATH="/app/.venv/bin:$PATH"
|
|
|
|
# Copy application code
|
|
COPY src/ ./src/
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Set entrypoint to restrict usage to uvicorn with this specific app
|
|
ENTRYPOINT ["uvicorn", "src.baby_monitor.main:app"]
|
|
|
|
# Default arguments
|
|
CMD ["--host", "0.0.0.0", "--port", "8000"]
|