Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Production ready Prompt Service dockerfile & Handling timeout exceptions #347

Merged
merged 5 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions docker/dockerfiles/prompt.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ ENV PDM_VERSION 2.12.3

RUN apt-get update; \
apt-get --no-install-recommends install -y \
# unstract sdk
build-essential libmagic-dev pandoc pkg-config tesseract-ocr \
# git url
git; \
# unstract sdk
build-essential libmagic-dev pandoc pkg-config tesseract-ocr \
# git url
git; \
apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \
\
pip install --no-cache-dir -U pip pdm~=${PDM_VERSION}; \
Expand Down Expand Up @@ -50,33 +50,33 @@ RUN set -e; \
#
for dir in "${TARGET_PLUGINS_PATH}"/*/; \
do \
# Remove trailing "/". \
dirpath=${dir%*/}; \
\
# If no plugins, final part on split by "/" is equal to "*". \
if [ "${dirpath##*/}" = "*" ]; then \
continue; \
fi; \
\
cd "$dirpath"; \
echo "Installing plugin: ${dirpath##*/}..."; \
\
# PDM reuses active venv unless PDM_IGNORE_ACTIVE_VENV is set.
pdm sync --prod --no-editable; \
\
cd -; \
# Remove trailing "/". \
dirpath=${dir%*/}; \
\
# If no plugins, final part on split by "/" is equal to "*". \
if [ "${dirpath##*/}" = "*" ]; then \
continue; \
fi; \
\
cd "$dirpath"; \
echo "Installing plugin: ${dirpath##*/}..."; \
\
# PDM reuses active venv unless PDM_IGNORE_ACTIVE_VENV is set.
pdm sync --prod --no-editable; \
\
cd -; \
done; \
#
#
#
\
# REF: https://docs.gunicorn.org/en/stable/deploy.html#using-virtualenv
pip install --no-cache-dir gunicorn; \
pip install --no-cache-dir gunicorn gevent; \
\
# Storage for prompt studio uploads
mkdir prompt-studio-data;

EXPOSE 3003

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD [".venv/bin/gunicorn", "--bind", "0.0.0.0:3003", "--timeout", "300", "unstract.prompt_service.main:app"]
CMD [ "./entrypoint.sh" ]
13 changes: 13 additions & 0 deletions prompt-service/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# 'src' layout is detected from pdm settings in pyproject.toml
.venv/bin/gunicorn \
--bind 0.0.0.0:3003 \
--workers 2 \
--threads 2 \
--worker-class gevent\
--log-level debug \
--timeout 900 \
--access-logfile - \
--reload \
unstract.prompt_service.main:app
Loading