# Template Dockerfile for ML Services # This uses the pre-built base-ml image which contains all heavy ML dependencies # Only the application code is added on top (~50MB vs 1.2GB) # # Usage: Copy this template to apps/svc_*/Dockerfile and replace SERVICE_NAME # Use the pre-built ML base image ARG REGISTRY=gitea.harkon.co.uk ARG OWNER=harkon ARG BASE_VERSION=v1.0.1 FROM ${REGISTRY}/${OWNER}/base-ml:${BASE_VERSION} # Switch to root to install service-specific dependencies USER root # Set working directory WORKDIR /app # Copy service-specific requirements (if any additional deps needed) # Most ML deps are already in base-ml, so this should be minimal COPY apps/SERVICE_NAME/requirements.txt /tmp/service-requirements.txt # Install any service-specific dependencies (should be very few) RUN if [ -s /tmp/service-requirements.txt ]; then \ pip install --no-cache-dir -r /tmp/service-requirements.txt; \ fi # Copy application code COPY libs/ ./libs/ COPY apps/SERVICE_NAME/ ./apps/SERVICE_NAME/ # Set permissions RUN chown -R appuser:appuser /app # Switch back to non-root user USER appuser # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/healthz || exit 1 # Expose port EXPOSE 8000 # Run the application CMD ["python", "-m", "uvicorn", "apps.SERVICE_NAME.main:app", "--host", "0.0.0.0", "--port", "8000"]