diff --git a/README.md b/README.md index e355760f..38763fc2 100644 --- a/README.md +++ b/README.md @@ -155,4 +155,4 @@ To run all the testcases, from the folder vachan-api/app run the command ```python -m pytest``` -For runing testselectively, refer [pytest docs](https://docs.pytest.org/en/stable/usage.html#specifying-tests-selecting-tests) +For runing testselectively, refer [pytest docs](https://docs.pytest.org/en/stable/usage.html#specifying-tests-selecting-tests) \ No newline at end of file diff --git a/app/main.py b/app/main.py index e1e13006..5e1b9141 100644 --- a/app/main.py +++ b/app/main.py @@ -35,6 +35,7 @@ app = FastAPI(title="Vachan-API", version="2.0.0", description=f"The server application that provides APIs to interact \ with the underlying Databases and modules in Vachan-Engine. \ +\n • For Vachan-CMS docs: {root_url}/v2/cms/rest/docs,\ \n • For Vachan-TBT docs: {root_url}/v2/text/translate/token-based/docs") template = Jinja2Templates(directory="templates") app.mount("/static", StaticFiles(directory="static"), name="static") @@ -241,13 +242,36 @@ def test(request: Request,db_: Session = Depends(get_db)): "/v2/files/usfm/to/{output_format}" ] +# def custom_openapi(): +# '''Modify the auto generated openapi schema for API docs''' +# openapi_schema = get_openapi(title="Vachan-API", version="2.0.0", +# description=f"The server application that provides APIs to interact \ +# with the underlying Databases and modules in Vachan-Engine. \ +#
Vachan-TBT docs ", +# routes=app.routes) + +# # Add version information to specific endpoints +# for path, path_data in openapi_schema["paths"].items(): +# for _, method_data in path_data.items(): +# if path in beta_endpoints: +# # Set endpoints as experimental in the API-docs +# method_data.setdefault("x-experimental", True) + +# return openapi_schema + def custom_openapi(): - '''Modify the auto generated openapi schema for API docs''' - openapi_schema = get_openapi(title="Vachan-API", version="2.0.0", - description=f"The server application that provides APIs to interact \ -with the underlying Databases and modules in Vachan-Engine. \ -
Vachan-TBT docs ", - routes=app.routes) + '''Modify the auto-generated OpenAPI schema for API docs''' + cms_href = " Vachan-CMS-REST docs " + tbt_href = " Vachan-TBT docs " + + openapi_schema = get_openapi( + title="Vachan-API", + version="2.0.0", + description=f"The server application that provides APIs to interact\ + with the underlying Databases and modules in Vachan-Engine.\ +
• {cms_href}
• {tbt_href}", + routes=app.routes + ) # Add version information to specific endpoints for path, path_data in openapi_schema["paths"].items(): diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 2a47c829..f2917dd8 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -3,7 +3,7 @@ services: kratos-postgresd: image: postgres:9.6 ports: - - "5432:5432" + - "5438:5432" expose: - 5432 restart: always @@ -91,7 +91,7 @@ services: - 5432 ports: # HOST:CONTAINER - - "5433:5432" + - "5439:5432" networks: - VE-network volumes: @@ -207,7 +207,35 @@ services: - deployment networks: - VE-network - + + vachan-cms-rest: + image: athulyams/vachan-cms-rest:v2.0.1 + # ports: + # - "8004:8004" + expose: + - 8005 + command: uvicorn main:app --host 0.0.0.0 --port 8005 + restart: always + environment: + - VACHAN_POSTGRES_HOST=vachan-db + - VACHAN_POSTGRES_PORT=5432 + - VACHAN_POSTGRES_USER=${VACHAN_POSTGRES_USER:-postgres} + - VACHAN_POSTGRES_PASSWORD=${VACHAN_POSTGRES_PASSWORD:-password} + - VACHAN_POSTGRES_DATABASE=${VACHAN_POSTGRES_DATABASE:-vachan_dev} + - VACHAN_POSTGRES_SCHEMA=vachan_cms_rest + - VACHAN_LOGGING_LEVEL=INFO + - VACHAN_DOMAIN=${VACHAN_DOMAIN:-http://localhost} + - VACHAN_CMS_DOMAIN=http://vachan-api + volumes: + - logs-vol:/app/logs + depends_on: + - vachan-db + profiles: + - local-run + - deployment + networks: + - VE-network + vachan-tbt: image: kavitha3797/vachan-tbt:v2.0.1 expose: @@ -266,7 +294,7 @@ services: web-server-local: image: nginx:latest ports: - - 80:80 + - 82:80 restart: always expose: - 80 diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf index eb3af0f5..31a069b2 100644 --- a/docker/nginx/default.conf +++ b/docker/nginx/default.conf @@ -19,6 +19,10 @@ server { proxy_set_header X-Forwarded-Proto $scheme; } + location /v2/cms/rest/ { + proxy_pass http://vachan-cms-rest:8005; + } + location /v2/text/translate/token-based/ { proxy_pass http://vachan-tbt:8003; } diff --git a/docker/nginx/prod/app.conf.template b/docker/nginx/prod/app.conf.template index 0fc3031c..d4000b76 100644 --- a/docker/nginx/prod/app.conf.template +++ b/docker/nginx/prod/app.conf.template @@ -41,6 +41,10 @@ server { proxy_pass http://vachan-cms-graphql:8004; } + location /v2/cms/rest/ { + proxy_pass http://vachan-cms-rest:8005; + } + location /v2/text/translate/token-based/ { proxy_pass http://vachan-tbt:8003; }