Chore/docker compose update (#69)

* update docker related settings

* change WREN_AI_SERVICE_PORT default 5555

* add pull_policy, restart condition and update wren-ai-service port

* fix default port for wren-ai-service
This commit is contained in:
Chih-Yu Yeh
2024-04-03 15:57:09 +08:00
committed by GitHub
parent c1c4241c1a
commit 69263e6dd9
11 changed files with 30 additions and 21 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ PLATFORM=linux/amd64
# service port
WREN_ENGINE_PORT=8080
WREN_ENGINE_SQL_PORT=7432
WREN_AI_SERVICE_PORT=80
WREN_AI_SERVICE_PORT=5555
# version
# CHANGE THIS TO THE LATEST VERSION
+6 -2
View File
@@ -10,6 +10,7 @@ networks:
services:
bootstrap:
image: ghcr.io/canner/wren-bootstrap:${WREN_BOOTSTRAP_VERSION}
pull_policy: always
platform: ${PLATFORM}
environment:
DATA_PATH: /app/data
@@ -19,6 +20,7 @@ services:
wren-engine:
image: ghcr.io/canner/wren-engine:${WREN_ENGINE_VERSION}
pull_policy: always
platform: ${PLATFORM}
expose:
- ${WREN_ENGINE_SQL_PORT}
@@ -33,11 +35,12 @@ services:
wren-ai-service:
image: ghcr.io/canner/wren-ai-service:${WREN_AI_SERVICE_VERSION}
pull_policy: always
platform: ${PLATFORM}
ports:
- 5000:${WREN_AI_SERVICE_PORT}
- ${WREN_AI_SERVICE_PORT}:${WREN_AI_SERVICE_PORT}
environment:
UVICORN_PORT: ${WREN_AI_SERVICE_PORT}
WREN_AI_SERVICE_PORT: ${WREN_AI_SERVICE_PORT}
OPENAI_API_KEY: ${OPENAI_API_KEY}
QDRANT_HOST: qdrant
WREN_ENGINE_ENDPOINT: http://wren-engine:${WREN_ENGINE_PORT}
@@ -51,6 +54,7 @@ services:
qdrant:
image: qdrant/qdrant:v1.7.4
pull_policy: always
expose:
- 6333
- 6334
+6 -1
View File
@@ -10,6 +10,7 @@ networks:
services:
bootstrap:
image: ghcr.io/canner/wren-bootstrap:${WREN_BOOTSTRAP_VERSION}
restart: on-failure
platform: ${PLATFORM}
environment:
DATA_PATH: /app/data
@@ -19,6 +20,7 @@ services:
wren-engine:
image: ghcr.io/canner/wren-engine:${WREN_ENGINE_VERSION}
restart: on-failure
platform: ${PLATFORM}
expose:
- ${WREN_ENGINE_PORT}
@@ -32,11 +34,12 @@ services:
wren-ai-service:
image: ghcr.io/canner/wren-ai-service:${WREN_AI_SERVICE_VERSION}
restart: on-failure
platform: ${PLATFORM}
expose:
- ${WREN_AI_SERVICE_PORT}
environment:
UVICORN_PORT: ${WREN_AI_SERVICE_PORT}
WREN_AI_SERVICE_PORT: ${WREN_AI_SERVICE_PORT}
OPENAI_API_KEY: ${OPENAI_API_KEY}
QDRANT_HOST: qdrant
WREN_ENGINE_ENDPOINT: http://wren-engine:${WREN_ENGINE_PORT}
@@ -51,6 +54,7 @@ services:
qdrant:
image: qdrant/qdrant:v1.7.4
restart: on-failure
expose:
- 6333
- 6334
@@ -61,6 +65,7 @@ services:
wren-ui:
image: ghcr.io/canner/wren-ui:${WREN_UI_VERSION}
restart: on-failure
platform: ${PLATFORM}
environment:
DB_TYPE: sqlite
+2 -2
View File
@@ -1,6 +1,6 @@
# fastapi related
UVICORN_HOST=127.0.0.1
UVICORN_PORT=5000
WREN_AI_SERVICE_HOST=127.0.0.1
WREN_AI_SERVICE_PORT=5555
# app related
QDRANT_HOST=localhost
+1 -1
View File
@@ -6,7 +6,7 @@
COMPOSE_PROJECT_NAME=wren
# fastapi related
UVICORN_PORT=5000
WREN_AI_SERVICE_PORT=5555
# app related
QDRANT_HOST=qdrant
+1 -1
View File
@@ -2,7 +2,7 @@ start:
poetry run python -m src.__main__
build:
docker compose -f docker/docker-compose.yml build
docker compose -f docker/docker-compose.yml --env-file .env.prod build
up:
make run-wren-engine && \
+1 -1
View File
@@ -11,7 +11,7 @@
## Start the service for development
- execute `make start` to start the service and go to `http://UVICORN_HOST:UVICORN_PORT` to see the API documentation and try the APIs
- execute `make start` to start the service and go to `http://WREN_AI_SERVICE_HOST:WREN_AI_SERVICE_PORT` to see the API documentation and try the APIs
## Production Environment Setup
+1 -1
View File
@@ -15,7 +15,7 @@ import sqlglot
import sqlparse
import streamlit as st
WREN_AI_SERVICE_BASE_URL = "http://127.0.0.1:5000"
WREN_AI_SERVICE_BASE_URL = "http://127.0.0.1:5555"
WREN_ENGINE_PG_URL = (
"postgres://localhost:7432/canner-cml?options=--search_path%3Dspider"
)
+1 -1
View File
@@ -23,4 +23,4 @@ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY src src
ENTRYPOINT [ "uvicorn", "src.__main__:app", "--host", "0.0.0.0", "--port", "80" ]
ENTRYPOINT uvicorn src.__main__:app --host 0.0.0.0 --port $WREN_AI_SERVICE_PORT
+2 -2
View File
@@ -11,7 +11,7 @@ services:
context: ..
dockerfile: docker/Dockerfile
environment:
UVICORN_PORT: ${UVICORN_PORT}
WREN_AI_SERVICE_PORT: ${WREN_AI_SERVICE_PORT}
OPENAI_API_KEY: ${OPENAI_API_KEY}
QDRANT_HOST: ${QDRANT_HOST}
WREN_ENGINE_ENDPOINT: ${WREN_ENGINE_ENDPOINT}
@@ -19,7 +19,7 @@ services:
# using PYTHONUNBUFFERED: 1 can fix this
PYTHONUNBUFFERED: 1
ports:
- ${UVICORN_PORT}:80
- ${WREN_AI_SERVICE_PORT}:${WREN_AI_SERVICE_PORT}
depends_on:
- qdrant
+8 -8
View File
@@ -13,11 +13,6 @@ from src.web.v1 import routers
env = load_env_vars()
server_host = os.getenv("UVICORN_HOST") or "127.0.0.1"
server_port = (
int(os.getenv("UVICORN_PORT")) if os.getenv("UVICORN_PORT") is not None else 8000
)
# https://fastapi.tiangolo.com/advanced/events/#lifespan
@asynccontextmanager
@@ -35,9 +30,7 @@ app = FastAPI(lifespan=lifespan, redoc_url=None)
app.include_router(routers.router, prefix="/v1")
app.add_middleware(
CORSMiddleware,
allow_origins=[
f"http://{server_host}:{server_port}",
],
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
@@ -66,6 +59,13 @@ def root():
if __name__ == "__main__":
server_host = os.getenv("WREN_AI_SERVICE_HOST") or "127.0.0.1"
server_port = (
int(os.getenv("WREN_AI_SERVICE_PORT"))
if os.getenv("WREN_AI_SERVICE_PORT") is not None
else 8000
)
uvicorn.run(
"src.__main__:app",
host=server_host,