build: Use uvicorn instead of gunicorn as server in REST API's Dockerfile (#4304)

* Use uvicorn instead of gunicorn as server

* Added comments and changed service names

* comments improvised

---------

Co-authored-by: Mayank Jobanputra <mayankjobanputra@gmail.com>
This commit is contained in:
bogdankostic 2023-03-08 21:16:07 +01:00 committed by GitHub
parent f90ffb6851
commit e3503a92c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -3,8 +3,10 @@ ARG base_image
FROM ${base_image}:${base_image_tag}
ENV SERVICE_NAME="gunicorn-service"
ENV SERVICE_NAME="haystackd"
# Haystack pipelines are run by the "haystackd" user.
# This helps keep the process and log management organized.
RUN addgroup --gid 1001 $SERVICE_NAME && \
adduser --gid 1001 --uid 1001 --shell /bin/false --disabled-password $SERVICE_NAME && \
mkdir -p /var/log/$SERVICE_NAME && \
@ -19,7 +21,8 @@ ENV FILE_UPLOAD_PATH="/opt/file-upload"
ENV TIKA_LOG_PATH="/var/log/$SERVICE_NAME/"
# The uvicorn server runs on port 8000, and it needs to be accessible from outside the container.
EXPOSE 8000
USER $SERVICE_NAME
CMD ["gunicorn", "rest_api.application:app", "-b", "0.0.0.0", "-k", "uvicorn.workers.UvicornWorker", "--workers", "1", "--timeout", "1000"]
CMD ["uvicorn", "rest_api.application:app", "--host", "0.0.0.0"]

View File

@ -28,7 +28,6 @@ dependencies = [
"farm-haystack",
"fastapi<1",
"uvicorn<1",
"gunicorn<21",
"python-multipart<1", # optional FastAPI dependency for form data
"pynvml",
"psutil"