|
1 | | -# Dockerfile for Mohawk Worker |
2 | | -FROM python:3.12-slim AS builder |
| 1 | +# Mohawk Inference Engine Worker - Production Docker Image |
| 2 | +# Version: 2.1.0 |
| 3 | +# Cross-platform: Windows, Linux, macOS |
3 | 4 |
|
4 | | -# Install system dependencies for liboqs |
5 | | -RUN apt-get update && apt-get install -y \ |
6 | | - build-essential \ |
7 | | - cmake \ |
8 | | - libssl-dev \ |
9 | | - pkg-config \ |
10 | | - && curl -sS https://liboqs.org/install.sh | bash \ |
11 | | - && ldconfig /usr/local/lib |
| 5 | +FROM python:3.11-slim-bookworm |
12 | 6 |
|
13 | | -# Create non-root user for security |
14 | | -RUN useradd -u 1000 -g 1000 appuser |
| 7 | +# Set environment variables for production |
| 8 | +ENV PYTHONDONTWRITEBYTECODE=1 \ |
| 9 | + PYTHONUNBUFFERED=1 \ |
| 10 | + PIP_NO_CACHE_DIR=1 \ |
| 11 | + PIP_DISABLE_PIP_VERSION_CHECK=1 \ |
| 12 | + DEBIAN_FRONTEND=noninteractive |
15 | 13 |
|
| 14 | +# Set working directory |
16 | 15 | WORKDIR /app |
17 | 16 |
|
18 | | -# Copy requirements and install Python dependencies |
| 17 | +# Install system dependencies |
| 18 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 19 | + # System libraries for PyQt6 (if needed) |
| 20 | + libgl1-mesa-glx \ |
| 21 | + libxkbcommon-x11-0 \ |
| 22 | + libdbus-1-3 \ |
| 23 | + libegl1-mesa \ |
| 24 | + # Build tools |
| 25 | + gcc \ |
| 26 | + git \ |
| 27 | + # ONNX runtime for model inference |
| 28 | + onnxruntime>=1.16.0 \ |
| 29 | + && rm -rf /var/lib/apt/lists/* |
| 30 | + |
| 31 | +# Install Python dependencies |
19 | 32 | COPY requirements.txt . |
20 | 33 | RUN pip install --no-cache-dir -r requirements.txt |
21 | 34 |
|
22 | 35 | # Copy application code |
| 36 | +COPY mohawk_gui/ ./mohawk_gui/ |
23 | 37 | COPY prototype/ ./prototype/ |
24 | 38 |
|
25 | | -# Set ownership for non-root user |
26 | | -RUN chown -R appuser:appuser /app |
| 39 | +# Create non-root user for security (production best practice) |
| 40 | +RUN groupadd mohawk && \ |
| 41 | + useradd -r -g mohawk mohawk && \ |
| 42 | + chown -R mohawk:mohawk /app |
| 43 | +USER mohawk |
27 | 44 |
|
28 | | -USER appuser |
| 45 | +# Create directories for runtime data |
| 46 | +RUN mkdir -p /app/certs /app/logs /app/models && \ |
| 47 | + chown -R mohawk:mohawk /app/certs /app/logs /app/models |
29 | 48 |
|
30 | | -# Expose worker port |
| 49 | +# Copy configuration template |
| 50 | +COPY mohawk_gui/config.toml ./config.toml |
| 51 | + |
| 52 | +# Expose ports |
31 | 53 | EXPOSE 8003 |
32 | 54 |
|
33 | 55 | # Health check |
34 | | -HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ |
35 | | - CMD curl -f http://localhost:8003/metrics || exit 1 |
| 56 | +HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ |
| 57 | + CMD python -c "import sys; print('OK'); sys.exit(0)" || exit 1 |
36 | 58 |
|
37 | | -# Run worker |
| 59 | +# Default command - can be overridden at runtime |
38 | 60 | CMD ["python", "prototype/worker_secure.py", "--port", "8003"] |
0 commit comments