-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
107 lines (81 loc) · 3.21 KB
/
Dockerfile
File metadata and controls
107 lines (81 loc) · 3.21 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
# Multi-stage Dockerfile for GitForAI
# Optimized for production use with minimal image size
# ============================================================================
# Stage 1: Builder - Install dependencies and build wheels
# ============================================================================
FROM python:3.10-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /build
# Copy dependency files and source code
COPY pyproject.toml ./
COPY src/ ./src/
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install Python dependencies and package with full support
# Includes: OpenAI API + sentence-transformers + torch + ChromaDB
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir ".[llm,local-embeddings,vectordb]"
# ============================================================================
# Stage 2: Runtime - Minimal production image
# ============================================================================
FROM python:3.10-slim AS runtime
# Install runtime dependencies only
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
openssh-client \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 -s /bin/bash gitforai
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Set environment variables
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Set working directory
WORKDIR /app
# Create directories for data
RUN mkdir -p /repos /output /cache /data /vectordb && \
chown -R gitforai:gitforai /repos /output /cache /data /vectordb /app
# Switch to non-root user
USER gitforai
# Create state directory for incremental updates
RUN mkdir -p /home/gitforai/.gitforai
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import gitforai; print(gitforai.__version__)" || exit 1
# Set default command
ENTRYPOINT ["gitforai"]
CMD ["--help"]
# ============================================================================
# Stage 3: Development - Full development environment
# ============================================================================
FROM runtime AS development
USER root
# Install development dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
vim \
curl \
&& rm -rf /var/lib/apt/lists/*
USER gitforai
# Install development Python packages with full support
RUN pip install --no-cache-dir -e ".[dev,llm,local-embeddings,vectordb]"
# Override entrypoint for development
ENTRYPOINT []
CMD ["/bin/bash"]
# ============================================================================
# Metadata
# ============================================================================
LABEL maintainer="GitForAI Team"
LABEL description="Git History Mining for AI Agents"
LABEL version="0.1.0"
# Document exposed ports (for future API service)
EXPOSE 8000
# Document volumes
VOLUME ["/repos", "/output", "/cache", "/data", "/vectordb", "/home/gitforai/.gitforai"]