mirror of
https://github.com/sstent/FitTrack_ReportGenerator.git
synced 2026-01-27 17:42:28 +00:00
This commit introduces the initial version of the FitTrack Report Generator, a FastAPI application for analyzing workout files. Key features include: - Parsing of FIT, TCX, and GPX workout files. - Analysis of power, heart rate, speed, and elevation data. - Generation of summary reports and charts. - REST API for single and batch workout analysis. The project structure has been set up with a `src` directory for core logic, an `api` directory for the FastAPI application, and a `tests` directory for unit, integration, and contract tests. The development workflow is configured to use Docker and modern Python tooling.
71 lines
1.9 KiB
Docker
71 lines
1.9 KiB
Docker
# Use multi-stage build with UV package manager
|
|
FROM python:3.12-slim AS builder
|
|
|
|
# Install minimal build dependencies and UV
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
# Create virtual environment using the correct uv path
|
|
RUN /root/.local/bin/uv venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
# Copy project definition
|
|
COPY pyproject.toml .
|
|
|
|
# Set environment for optimized wheels
|
|
ENV UV_EXTRA_INDEX_URL=https://pypi.org/simple
|
|
ENV UV_FIND_LINKS=https://download.pytorch.org/whl/torch_stable.html
|
|
|
|
# Install dependencies with UV - use pre-compiled SciPy wheel with OpenBLAS optimization
|
|
RUN /root/.local/bin/uv pip install \
|
|
--only-binary=scipy \
|
|
-r pyproject.toml
|
|
|
|
# Final runtime stage
|
|
FROM python:3.12-slim
|
|
|
|
# Install only essential runtime libraries
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libgomp1 \
|
|
libgfortran5 \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& apt-get clean
|
|
|
|
# Copy virtual environment from builder
|
|
COPY --from=builder /opt/venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy application files
|
|
COPY garminsync/ ./garminsync/
|
|
COPY migrations/ ./migrations/
|
|
COPY migrations/alembic.ini ./alembic.ini
|
|
COPY entrypoint.sh .
|
|
COPY patches/garth_data_weight.py ./garth_data_weight.py
|
|
|
|
# Apply patches
|
|
RUN cp garth_data_weight.py /opt/venv/lib/python3.12/site-packages/garth/data/weight.py
|
|
|
|
# Set permissions
|
|
RUN chmod +x entrypoint.sh
|
|
|
|
# Create data directory
|
|
RUN mkdir -p /app/data
|
|
|
|
# Create non-root user
|
|
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
|
RUN chown -R appuser:appuser /app
|
|
USER appuser
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8888/health || exit 1
|
|
|
|
ENTRYPOINT ["./entrypoint.sh"]
|
|
EXPOSE 8888
|