Files
baby-monitor/Dockerfile
T
Brian Bjarke Jensen 298fb192de
Python Code Quality / python-code-quality (push) Successful in 9s
Python Test / python-test (push) Successful in 12s
fixed tests
2025-11-04 21:50:58 +01:00

47 lines
1.0 KiB
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 \
ENVIRONMENT=production
# 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 README.md ./
# 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/
# Add healthcheck
HEALTHCHECK \
--interval=30s \
--timeout=30s \
--start-period=5s \
--retries=3 \
CMD python -c "import urllib.request; \
urllib.request.urlopen('http://localhost:8000/health', timeout=10)"
# 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"]