-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from AaltoRSE/dockerfile_fastapi_gunicorn_uvicorn
- Loading branch information
Showing
6 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
# https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker | ||
# https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker/blob/master/docker-images/python3.11.dockerfile | ||
FROM tiangolo/uvicorn-gunicorn:python3.11 | ||
# Dockerfile | ||
FROM mambaorg/micromamba:latest | ||
|
||
COPY requirements.txt /tmp/requirements.txt | ||
RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
USER root | ||
|
||
COPY ./app /app | ||
# Run apt install | ||
RUN apt-get update -y && apt-get upgrade -y | ||
|
||
# Don't write .pyc files into image to reduce image size | ||
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 | ||
|
||
# Install conda environment to /opt/env/ and prepend to PATH | ||
COPY environment.yml /opt/ | ||
RUN micromamba create -f /opt/environment.yml -p /opt/env/ | ||
ENV PATH="/opt/env/bin:$PATH" | ||
|
||
# Change work directory | ||
WORKDIR / | ||
|
||
# Copy application contents | ||
COPY ./app . | ||
COPY ./entrypoint.sh . | ||
|
||
# run the container as a non-root user | ||
ENV USER=aaltorse | ||
RUN groupadd -r $USER && useradd -r -g $USER $USER | ||
USER $USER | ||
|
||
# Entrypoint | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
# LLMGateway | ||
|
||
An API gateway for Aalto LLM deployment. | ||
|
||
Implemented as a FastAPI app, served using gunicorn + uvicorn, and containerized using Docker. | ||
|
||
## Run container locally | ||
|
||
Build image and run container | ||
``` | ||
docker build -t llmgateway . | ||
docker run -p 8000:8000 llmgateway | ||
``` | ||
|
||
Test the connection | ||
``` | ||
curl 0.0.0.0:8000 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
""" | ||
A placeholder hello world app. | ||
""" | ||
|
||
from typing import Union | ||
|
||
from fastapi import FastAPI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
gunicorn app.main:app --bind 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker --workers 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ channels: | |
- conda-forge | ||
dependencies: | ||
- fastapi | ||
- gunicorn | ||
- uvicorn | ||
- redis-py | ||
- pymongo | ||
- schedule |
This file was deleted.
Oops, something went wrong.