File size: 1,228 Bytes
f3704c3
 
 
029c5e8
f3704c3
 
029c5e8
f3704c3
 
 
 
 
 
 
029c5e8
 
 
f3704c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
029c5e8
 
f3704c3
 
 
 
 
 
 
 
 
 
 
 
 
 
029c5e8
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
# Declare build arguments at the top (for initial stage)
ARG USER_UID=1000
ARG USER_GID=1000

# Stage 1: Build dependencies
FROM python:3.11-slim AS builder
WORKDIR /app
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential \
    git && \
    rm -rf /var/lib/apt/lists/*
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Stage 2: Final image
FROM python:3.11-slim

# Re-declare build arguments for this stage
ARG USER_UID=1000
ARG USER_GID=1000

COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /app
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    libgomp1 && \
    rm -rf /var/lib/apt/lists/*

COPY . .

# Create the group and user first
RUN groupadd -g ${USER_GID} appuser && \
    useradd -m -u ${USER_UID} -g appuser appuser

# Create directories and set permissions
RUN mkdir -p /app/Rag/chromadb.db && \
    mkdir -p /app/Data && \
    chown -R appuser:appuser /app

USER appuser

# Make sure your Python code uses this path for ChromaDB
ENV CHROMA_PERSISTENCE_DIRECTORY=/app/Rag/chromadb.db

CMD ["python", "-m", "Example.rag_example"]