major-domo-database/Dockerfile
Cal Corum 4acf7b2afa feat: expose running CalVer version via API (#126)
Closes #126

- Dockerfile: ARG BUILD_VERSION=dev baked into ENV APP_VERSION + OCI label
- CI: passes BUILD_VERSION build-arg from git tag to docker build
- main.py: adds GET /health returning {"status": "ok", "version": "..."}
- Dockerfile: updates HEALTHCHECK to use /health (no SQL, lightweight)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 15:53:55 +00:00

39 lines
1.1 KiB
Docker

# Use official Python slim image
FROM python:3.12-slim
# Build-time version arg — passed by CI from the git tag
ARG BUILD_VERSION=dev
LABEL org.opencontainers.image.version=$BUILD_VERSION
# Set Python optimizations
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=1
# Bake the CalVer version into the image so it's readable at runtime
ENV APP_VERSION=$BUILD_VERSION
WORKDIR /usr/src/app
# Install system dependencies (PostgreSQL client libraries)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY ./app /usr/src/app/app
# Create directories for volumes
RUN mkdir -p /usr/src/app/storage
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:80/health || exit 1
# Start uvicorn
ENV WEB_WORKERS=2
CMD ["sh", "-c", "exec uvicorn app.main:app --host 0.0.0.0 --port 80 --workers $WEB_WORKERS"]