Skip to content

Commit

Permalink
Merge pull request #60 from SCAI-BIO/configure-api-prod-url
Browse files Browse the repository at this point in the history
Add docker configurable production url to Dockerfile.prod
  • Loading branch information
tiadams authored Aug 22, 2024
2 parents ad884b8 + 2f4a4db commit e853e87
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./api
file: ./api/Dockerfile
file: ./api/Dockerfile.prod
push: true
tags: |
ghcr.io/scai-bio/index/api:latest
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions api/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Define the base image
FROM python:3.9

ENV WEAVIATE_URL=http://ww8.index.k8s.bio.scai.fraunhofer.de

COPY routes.py .

# Install API requirements
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt

EXPOSE 80

# API entry point
CMD ["uvicorn", "routes:app", "--host", "0.0.0.0", "--port", "80"]
13 changes: 6 additions & 7 deletions api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
import time

import uvicorn
from datastew import DataDictionarySource, BaseRepository
from datastew import DataDictionarySource
from datastew.embedding import MPNetAdapter
from datastew.process.ols import OLSTerminologyImportTask
from datastew.repository import WeaviateRepository

from datastew.repository.model import Terminology, Concept, Mapping
from datastew.visualisation import get_plot_for_current_database_state
from fastapi import FastAPI, HTTPException, File, UploadFile
from starlette.background import BackgroundTasks
from starlette.middleware.cors import CORSMiddleware
from starlette.responses import RedirectResponse, HTMLResponse

from datastew.repository.model import Terminology, Concept, Mapping
from datastew.embedding import MPNetAdapter
from datastew.visualisation import get_plot_for_current_database_state

app = FastAPI(
title="INDEX",
description="<div id=info-text><h1>Introduction</h1>"
Expand Down Expand Up @@ -50,10 +48,11 @@


def connect_to_remote_weaviate_repository():
weaviate_url = os.getenv("WEAVIATE_URL", "http://weaviate:8080")
retries = 5
for i in range(retries):
try:
return WeaviateRepository(mode="remote", path="http://weaviate:8080")
return WeaviateRepository(mode="remote", path=weaviate_url)
except Exception as e:
logger.info(f"Attempt {i + 1} failed: {e}")
time.sleep(5)
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
image: index-api
build:
context: ./api
dockerfile: Dockerfile
dockerfile: Dockerfile.dev
ports:
- "5000:80"
depends_on:
Expand Down

0 comments on commit e853e87

Please sign in to comment.