-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
117 lines (93 loc) · 3.6 KB
/
Dockerfile
File metadata and controls
117 lines (93 loc) · 3.6 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# ============================================================================
# Perpendicularity - Multi-stage Production Dockerfile
#
# This Dockerfile builds a complete Perpendicularity container with:
# - Python backend (FastAPI API + CLI)
# - React frontend (built static files)
# - All dependencies optimized for production
#
# Standard build (cloud APIs only, ~500MB):
# docker build -t perpendicularity:latest .
#
# With local models (includes torch/transformers, ~2GB):
# docker build -t perpendicularity:local --build-arg INSTALL_LOCAL_MODELS=true .
#
# Run:
# docker run -p 8000:8000 perpendicularity:latest
# ============================================================================
# ============================================================================
# Stage 1: Build Frontend
# ============================================================================
FROM node:20-alpine AS frontend-builder
WORKDIR /frontend
# Copy package files
COPY frontend/package*.json ./
# Install dependencies (including dev deps needed for build like tsc, vite)
RUN npm ci
# Copy frontend source
COPY frontend/ ./
COPY assets/ ../assets/
# Build frontend (creates dist/ folder)
# Override Vite's outDir config to use standard dist/
RUN npm run build -- --outDir dist
# ============================================================================
# Stage 2: Python Dependencies
# ============================================================================
FROM python:3.11-slim AS python-builder
# Build argument for optional local models
ARG INSTALL_LOCAL_MODELS=false
WORKDIR /app
# Install uv for fast dependency installation
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Copy Python dependency files AND source code for installation
COPY pyproject.toml uv.lock README.md ./
COPY agent/ ./agent/
COPY cli/ ./cli/
COPY api/ ./api/
# Install Python dependencies and the package itself
# By default: lightweight (no torch/transformers)
# With --build-arg INSTALL_LOCAL_MODELS=true: includes local models
RUN if [ "$INSTALL_LOCAL_MODELS" = "true" ]; then \
echo "Installing with local models (torch, transformers)..."; \
uv sync --frozen --no-dev --extra api --extra local-models; \
else \
echo "Installing without local models (cloud APIs only)..."; \
uv sync --frozen --no-dev --extra api; \
fi
# ============================================================================
# Stage 3: Final Runtime Image
# ============================================================================
FROM python:3.11-slim
# Metadata
LABEL maintainer="Tobias Neumann <tobias.neumann.at@gmail.com>"
LABEL description="Perpendicularity - AI Drug Discovery Agent"
LABEL version="0.3.0"
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy Python environment from builder
COPY --from=python-builder /app/.venv /app/.venv
# Copy application code
COPY agent/ ./agent/
COPY cli/ ./cli/
COPY api/ ./api/
COPY config/ ./config/
COPY assets/ ./assets/
COPY pyproject.toml README.md ./
# Copy built frontend to API static directory
COPY --from=frontend-builder /frontend/dist ./api/static
# Add virtual environment to PATH
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH="/app"
# Create directories for user data
RUN mkdir -p /app/data /app/outputs
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/api/health || exit 1
# Expose API port
EXPOSE 8000
# Default command: Start API server via unified CLI
CMD ["perpendicularity", "api"]