-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (52 loc) · 1.84 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (52 loc) · 1.84 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
68
69
70
# LatentGate Dockerfile
# Multi-stage build for smaller image size
# Stage 1: Build stage
FROM python:3.11-slim AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy project files
COPY pyproject.toml README.md LICENSE ./
COPY latent_gate/ ./latent_gate/
# Install the package with API dependencies
RUN pip install --no-cache-dir --user ".[api]"
# Stage 2: Runtime stage
FROM python:3.11-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder
COPY --from=builder /root/.local /root/.local
# Copy application code
COPY latent_gate/ ./latent_gate/
COPY pyproject.toml README.md LICENSE ./
# Create non-root user
RUN useradd --create-home --shell /bin/bash appuser
# Make local packages accessible to appuser
RUN cp -r /root/.local /home/appuser/.local && \
chown -R appuser:appuser /home/appuser/.local
# Set environment variables
ENV PATH=/home/appuser/.local/bin:$PATH
ENV PYTHONUNBUFFERED=1
ENV LATENTGATE_LOG_LEVEL=INFO
ENV LATENTGATE_REMOTE_PROVIDER=ollama
ENV LATENTGATE_REMOTE_MODEL=llama3:8b
ENV LATENTGATE_VISION_MODEL=llava:7b
ENV LATENTGATE_TEXT_FAST_MODEL=phi3:mini
ENV LATENTGATE_TEXT_SMART_MODEL=qwen2:7b
ENV LATENTGATE_EMBEDDING_MODEL=nomic-embed-text
ENV LATENTGATE_OLLAMA_BASE_URL=http://ollama:11434
USER appuser
# Create cache directory
RUN mkdir -p /home/appuser/.latentgate_cache
# Expose API port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
# Default command: run API server
CMD ["latent-gate-api"]