feat: Created multi-stage Dockerfile.engine with healthcheck endpoint;…
- "docker/Dockerfile.engine" - "engine/api/routes.py" - ".dockerignore" GSD-Task: S03/T02
This commit is contained in:
parent
32eb02ccb6
commit
1f1629e6e9
3 changed files with 90 additions and 0 deletions
22
.dockerignore
Normal file
22
.dockerignore
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Kerf Engine — Docker build context exclusions
|
||||||
|
.git
|
||||||
|
.gsd
|
||||||
|
.venv
|
||||||
|
venv
|
||||||
|
__pycache__
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
.pytest_cache
|
||||||
|
*.egg-info
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
dist
|
||||||
|
build
|
||||||
|
coverage
|
||||||
|
.cache
|
||||||
|
tmp
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
61
docker/Dockerfile.engine
Normal file
61
docker/Dockerfile.engine
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
# ── Kerf Engine — multi-stage Docker build ──
|
||||||
|
# Standalone raster-to-vector conversion API (no App dependencies)
|
||||||
|
|
||||||
|
# ── Stage 1: Build dependencies ──
|
||||||
|
FROM python:3.11-slim AS builder
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
pkg-config \
|
||||||
|
libagg-dev \
|
||||||
|
libpotrace-dev \
|
||||||
|
libpotrace0 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
# Install Python deps into a virtual-env we can copy later
|
||||||
|
RUN python -m venv /opt/venv
|
||||||
|
ENV PATH="/opt/venv/bin:$PATH"
|
||||||
|
|
||||||
|
COPY engine/pyproject.toml .
|
||||||
|
RUN pip install --no-cache-dir . 2>/dev/null || true
|
||||||
|
# The above may fail because package source isn't present yet — install deps directly
|
||||||
|
RUN pip install --no-cache-dir \
|
||||||
|
"fastapi>=0.110" \
|
||||||
|
"uvicorn[standard]>=0.29" \
|
||||||
|
"opencv-python-headless>=4.9" \
|
||||||
|
"pypotrace>=0.3" \
|
||||||
|
"vtracer>=0.6" \
|
||||||
|
"python-multipart>=0.0.9" \
|
||||||
|
"Pillow>=10.2" \
|
||||||
|
"ezdxf>=1.0"
|
||||||
|
|
||||||
|
# ── Stage 2: Runtime image ──
|
||||||
|
FROM python:3.11-slim AS runtime
|
||||||
|
|
||||||
|
# Runtime-only system libs for pypotrace
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
libpotrace0 \
|
||||||
|
libagg2 \
|
||||||
|
curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy the virtual-env from the builder
|
||||||
|
COPY --from=builder /opt/venv /opt/venv
|
||||||
|
ENV PATH="/opt/venv/bin:$PATH"
|
||||||
|
|
||||||
|
# Copy engine source only — no App code
|
||||||
|
WORKDIR /app
|
||||||
|
COPY engine/main.py .
|
||||||
|
COPY engine/api/ ./api/
|
||||||
|
COPY engine/pipeline/ ./pipeline/
|
||||||
|
COPY engine/output/ ./output/
|
||||||
|
COPY engine/presets/ ./presets/
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \
|
||||||
|
CMD curl -sf http://localhost:8000/engine/health || exit 1
|
||||||
|
|
||||||
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
|
|
@ -14,6 +14,13 @@ from presets.loader import all_presets, preset_names, resolve_params
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/engine/health")
|
||||||
|
async def health():
|
||||||
|
"""Healthcheck endpoint for container orchestration."""
|
||||||
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
|
||||||
VALID_MODES = {"potrace", "vtracer"}
|
VALID_MODES = {"potrace", "vtracer"}
|
||||||
VALID_OUTPUT_FORMATS = {"svg", "dxf", "json"}
|
VALID_OUTPUT_FORMATS = {"svg", "dxf", "json"}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue