Nightwing11 commited on
Commit
5653764
·
1 Parent(s): 10ddbb3

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -0
Dockerfile ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Declare build arguments at the top (for initial stage)
2
+ ARG USER_UID=1000
3
+ ARG USER_GID=1000
4
+
5
+ # Stage 1: Build dependencies
6
+ FROM python:3.11-slim AS builder
7
+ WORKDIR /app
8
+ RUN apt-get update && \
9
+ apt-get install -y --no-install-recommends \
10
+ build-essential \
11
+ git && \
12
+ rm -rf /var/lib/apt/lists/*
13
+ RUN python -m venv /opt/venv
14
+ ENV PATH="/opt/venv/bin:$PATH"
15
+ COPY requirements.txt .
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # Stage 2: Final image
19
+ FROM python:3.11-slim
20
+
21
+ # Re-declare build arguments for this stage
22
+ ARG USER_UID=1000
23
+ ARG USER_GID=1000
24
+
25
+ COPY --from=builder /opt/venv /opt/venv
26
+ ENV PATH="/opt/venv/bin:$PATH"
27
+ WORKDIR /app
28
+ RUN apt-get update && \
29
+ apt-get install -y --no-install-recommends \
30
+ libgomp1 && \
31
+ rm -rf /var/lib/apt/lists/*
32
+
33
+ COPY . .
34
+
35
+ # Create the group and user first
36
+ RUN groupadd -g ${USER_GID} appuser && \
37
+ useradd -m -u ${USER_UID} -g appuser appuser
38
+
39
+ # Create directories and set permissions
40
+ RUN mkdir -p /app/Rag/chromadb.db && \
41
+ mkdir -p /app/Data && \
42
+ chown -R appuser:appuser /app
43
+
44
+ USER appuser
45
+
46
+ # Make sure your Python code uses this path for ChromaDB
47
+ ENV CHROMA_PERSISTENCE_DIRECTORY=/app/Rag/chromadb.db
48
+
49
+ CMD ["python", "-m","Example.rag_example"]