File size: 1,461 Bytes
51ddb70
 
071a570
 
 
 
 
51ddb70
071a570
51ddb70
 
 
 
e7fe59d
673263a
 
e7fe59d
51ddb70
 
aa249b7
21897b0
51ddb70
 
 
5af6686
 
51ddb70
3e5e205
 
 
51ddb70
e004610
98446e0
51ddb70
 
 
071a570
 
 
51ddb70
a820508
fc5c20c
 
ba5dfc5
a820508
b3a8793
7ac85a3
28918f9
97ecbbb
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
FROM python:3.11.6-slim-bookworm as base

# Install poetry
RUN pip install pipx
RUN python3 -m pipx ensurepath
RUN pipx install poetry
ENV PATH="/root/.local/bin:$PATH"

# https://python-poetry.org/docs/configuration/#virtualenvsin-project
ENV POETRY_VIRTUALENVS_IN_PROJECT=true

FROM base as dependencies
WORKDIR /home/worker/app
COPY pyproject.toml poetry.lock ./

# Explicitly copy the project files before running poetry install
COPY pyproject.toml poetry.lock ./
RUN poetry config installer.max-workers 10
RUN poetry install --with ui
RUN pip install fastapi uvicorn

FROM base as app

ENV PYTHONUNBUFFERED=1
ENV PORT=7860
EXPOSE 7860

# Prepare a non-root user
RUN adduser --system worker
WORKDIR /home/worker/app

# Ensure the worker user has the necessary permissions
RUN mkdir -p local_data/private_gpt/qdrant && chown -R worker local_data/private_gpt

# Copy only the necessary files for the app
COPY --chown=worker --from=dependencies /home/worker/app/.venv/ .venv
COPY --chown=worker private_gpt/ private_gpt
COPY --chown=worker docs/ docs
COPY --chown=worker *.yaml *.md ./

# Ensure the 'meta.json' file has the correct permissions
RUN touch local_data/private_gpt/qdrant/meta.json && chown worker local_data/private_gpt/qdrant/meta.json

RUN chmod 777 local_data/private_gpt/qdrant/meta.json

USER worker

# Activate the virtual environment and run uvicorn
CMD [".venv/bin/uvicorn", "private_gpt.main:app", "--host", "0.0.0.0", "--port", "7860"]