Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (53 loc) · 1.69 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (53 loc) · 1.69 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
# CodeRAG Dockerfile
# Multi-stage build for production deployment
# Stage 1: Builder
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 \
git \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY pyproject.toml ./
RUN pip install --no-cache-dir build && \
pip wheel --no-cache-dir --wheel-dir /wheels .
# Stage 2: Runtime
FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app/src \
HF_HOME=/app/data/hf_cache \
TRANSFORMERS_CACHE=/app/data/hf_cache \
TORCH_HOME=/app/data/torch_cache
WORKDIR /app
# Install Python and runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
python3.11-venv \
git \
&& rm -rf /var/lib/apt/lists/* \
&& ln -sf /usr/bin/python3.11 /usr/bin/python
# Copy wheels from builder
COPY --from=builder /wheels /wheels
# Install the application
RUN pip install --no-cache-dir /wheels/*.whl && \
rm -rf /wheels
# Copy application code
COPY src/ /app/src/
COPY configs/ /app/configs/
# Create data directories
RUN mkdir -p /app/data/chroma_db /app/data/repos /app/data/hf_cache /app/data/torch_cache
# Create non-root user
RUN useradd -m -u 1000 coderag && \
chown -R coderag:coderag /app
USER coderag
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:8000/health')" || exit 1
# Expose port
EXPOSE 8000
# Run the application
CMD ["python", "-m", "coderag.main"]