-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (52 loc) · 2.61 KB
/
Copy pathDockerfile
File metadata and controls
67 lines (52 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# HYDRA Arm 3 — Regulatory Intelligence SaaS
# Multi-stage Docker build for production deployment
# ─────────────────────────────────────────────────────────────
# Stage 1: Builder — install dependencies
# ─────────────────────────────────────────────────────────────
FROM python:3.11-slim AS builder
# System dependencies for cryptographic libraries and lxml
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libssl-dev \
libffi-dev \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy requirements and install Python dependencies
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /tmp/requirements.txt
# ─────────────────────────────────────────────────────────────
# Stage 2: Runtime — minimal production image
# ─────────────────────────────────────────────────────────────
FROM python:3.11-slim AS runtime
# Non-root user for security
RUN groupadd -r hydra && useradd -r -g hydra -d /app -s /sbin/nologin hydra
# 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 code
COPY config/ ./config/
COPY src/ ./src/
# Discovery assets — REQUIRED. Without these the .well-known manifests, sitemap,
# robots, favicon, apis.json and landing page 404 in production, making HYDRA
# invisible to crawlers, x402scan, Glama, Smithery and the x402 Bazaar.
COPY static/ ./static/
COPY index.html ./index.html
COPY .env.example .env.example
# Ensure Python can find the app root
ENV PYTHONPATH=/app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Port 8402 — HTTP 402 reference
EXPOSE 8402
# Switch to non-root user
USER hydra
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8402/health')" || exit 1
# Start server
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8402", "--workers", "1", "--log-level", "info"]