Spaces:
Sleeping
Sleeping
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"] | |