-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (55 loc) · 1.78 KB
/
Dockerfile
File metadata and controls
73 lines (55 loc) · 1.78 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
# Multi-stage build for ContextOptimizer
FROM node:18-alpine AS frontend-builder
# Set working directory for frontend
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
COPY frontend/tsconfig.json ./
COPY frontend/next.config.js ./
COPY frontend/tailwind.config.js ./
COPY frontend/postcss.config.js ./
COPY frontend/.eslintrc.json ./
# Install frontend dependencies
RUN npm ci --only=production
# Copy frontend source code
COPY frontend/src ./src
# Build frontend
RUN npm run build
# Python backend stage
FROM python:3.12-slim AS backend
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PATH="/opt/venv/bin:$PATH"
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
# Set working directory
WORKDIR /app
# Copy backend requirements
COPY backend/pyproject.toml ./backend/
COPY backend/uv.lock ./backend/
# Install uv and Python dependencies
RUN pip install uv
RUN cd backend && uv pip install -e .
# Copy backend source code
COPY backend ./backend
# Copy built frontend
COPY --from=frontend-builder /app/frontend/.next ./frontend/.next
COPY --from=frontend-builder /app/frontend/public ./frontend/public
COPY --from=frontend-builder /app/frontend/package.json ./frontend/
# Create necessary directories
RUN mkdir -p /app/data/uploads
RUN mkdir -p /app/data/sessions
RUN mkdir -p /app/logs
RUN mkdir -p /app/backend/test_data
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/api/v1/health || exit 1
# Start command
CMD ["python", "-m", "uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]