mirror of
https://github.com/Canner/WrenAI.git
synced 2026-09-24 23:29:49 +08:00
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:
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
COMPOSE_PROJECT_NAME=wren
|
||||
|
||||
# fastapi related
|
||||
UVICORN_PORT=5000
|
||||
WREN_AI_SERVICE_PORT=5555
|
||||
|
||||
# app related
|
||||
QDRANT_HOST=qdrant
|
||||
|
||||
@@ -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 && \
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user