Skip to content

Commit

Permalink
Merge pull request #43 from baloise/main
Browse files Browse the repository at this point in the history
add host flavor for deployment
  • Loading branch information
robbizbal authored Nov 13, 2024
2 parents def917f + 3bedfa1 commit a46008e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ EXPOSE 8000
# set poetry environment variables
ARG POETRY_FLAGS="--only main"
ARG LOAD_NER_MODELS="False"
ARG HOST_FLAVOR="default"

# set default environment variables
ENV OLLAMA_BASE_URL=http://localhost:11434 \
OLLAMA_MODEL=llama3.2:latest \
DEBIAN_FRONTEND=noninteractive \
HTTPX_CLIENT_VERIFY=
HTTPX_CLIENT_VERIFY= \
HOST_FLAVOR=$HOST_FLAVOR

# add app src
COPY . /app/
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ dev: $(INSTALL_STAMP)
# Run target to execute the application for production
run: $(INSTALL_STAMP)
# $(POETRY) run gunicorn src.app:app --workers 4 --worker-class uvicorn.workers.UvicornWorker
@echo "default mode"
$(POETRY) run uvicorn src.app:app --host 0.0.0.0 --port 8000

runos: $(INSTALL_STAMP)
@echo "openshift mode"
/home/anon/.local/bin/poetry run uvicorn src.app:app --host 0.0.0.0 --port 8000

loadModels: $(INSTALL_STAMP)
$(POETRY) run python src/utils/ano_spacy.py loadModels

12 changes: 10 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/bin/sh
#!/bin/bash

# Execute the command passed to the container
echo "$(cat banner.txt)"

# Define your dictionary as an associative array
declare -A flavor

# Add key-value pairs
flavor["openshift"]="make runos"
flavor["default"]="make run"

if [ -z "$@" ]; then
export PATH="$HOME/.local/bin:$PATH"
make run
echo "starting with flavor: $HOST_FLAVOR"
eval "${flavor[$HOST_FLAVOR]}"
fi

# Execute the command passed to the container
Expand Down
6 changes: 5 additions & 1 deletion src/templates/html/mask.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ <h3>Masked text</h3>
</main>

<footer class="flex-container-row">
<div class="flex-item"></div>
<div class="flex-item">
<a class="url-nounderline" target="_blank" href="/docs">
API Doc
</a>
</div>
<div class="flex-item">
<a target="_blank" href="https://github.com/baloise/yo-yo-maskr">
<img src="/static/public/github-mark.svg" alt="GitHub" width="30" height="30">
Expand Down
1 change: 1 addition & 0 deletions src/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL")
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL")
HTTPX_CLIENT_VERIFY = os.getenv("HTTPX_CLIENT_VERIFY")
HOST_FLAVOR = os.getenv("HOST_FLAVOR")

0 comments on commit a46008e

Please sign in to comment.