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

run our server with TLS #102

Merged
merged 2 commits into from
Jan 17, 2025
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ __pycache__/
*.py[cod]
*$py.class

/server/fullchain.pem
/server/privkey.pem
/server/cert.pem

# C extensions
*.so

Expand Down
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM fedora:40
# Fedora's llama-cpp-python is segfaulting on the mistral model we use :/
RUN dnf install -y fastapi-cli python3-fastapi python3-requests python3-drain3 python3-pip python3-pydantic-settings python3-starlette+full \
gcc gcc-c++ python3-scikit-build git-core \
gcc gcc-c++ python3-scikit-build git-core python3-gunicorn \
&& dnf clean all
# the newest 0.2.86 fails to build, it seems vendored llama-cpp is missing in the archive
RUN pip3 install llama_cpp_python==0.2.85 sse-starlette starlette-context \
Expand Down
3 changes: 2 additions & 1 deletion docker-compose-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ services:
- "${LOGDETECTIVE_SERVER_PORT:-8080}:${LOGDETECTIVE_SERVER_PORT:-8080}"
env_file: .env
# --no-reload: doesn't work in a container - `PermissionError: Permission denied (os error 13) about ["/proc"]`
command: fastapi run /src/logdetective/server.py --host 0.0.0.0 --port $LOGDETECTIVE_SERVER_PORT --no-reload
# command: fastapi run /src/logdetective/server.py --host 0.0.0.0 --port $LOGDETECTIVE_SERVER_PORT --no-reload
command: ["gunicorn", "-c", "/src/server/gunicorn-prod.config.py", "logdetective.server:app"]
4 changes: 3 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ services:
- "${LOGDETECTIVE_SERVER_PORT:-8080}:${LOGDETECTIVE_SERVER_PORT:-8080}"
env_file: .env
# --no-reload: doesn't work in a container - `PermissionError: Permission denied (os error 13) about ["/proc"]`
command: fastapi dev /src/logdetective/server.py --host 0.0.0.0 --port $LOGDETECTIVE_SERVER_PORT --no-reload
# command: fastapi dev /src/logdetective/server.py --host 0.0.0.0 --port $LOGDETECTIVE_SERVER_PORT --no-reload
# timeout set to 240 - 4 minutes should be enough for one LLM execution locally on a CPU
command: ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "--timeout", "240", "logdetective.server:app", "-b", "0.0.0.0:$LOGDETECTIVE_SERVER_PORT"]
11 changes: 11 additions & 0 deletions server/gunicorn-prod.config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
bind = f"0.0.0.0:{os.environ['LOGDETECTIVE_SERVER_PORT']}"
worker_class = "uvicorn.workers.UvicornWorker"
Dismissed Show dismissed Hide dismissed
workers = 2
Dismissed Show dismissed Hide dismissed
# timeout set to 120 - 2 minutes should be enough for one LLM execution in production on a GPU
timeout = 120
Dismissed Show dismissed Hide dismissed
# write to stdout
accesslog = '-'
Dismissed Show dismissed Hide dismissed
certfile = "/src/server/cert.pem"
Dismissed Show dismissed Hide dismissed
keyfile = "/src/server/privkey.pem"
Dismissed Show dismissed Hide dismissed
ca_certs = "/src/server/fullchain.pem"
Dismissed Show dismissed Hide dismissed
Loading