diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index fbd94e7..91701d4 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -1,18 +1,6 @@ # Deployment -## Azure -Create and set the environment variables based on `.env.template`. Make sure +Note on the container: Create and set the environment variables based on `.env.template`. Make sure `FINESSE_BACKEND_DEBUG_MODE` is NOT set to `True` in PRODUCTION builds. -Build (do this from your WSL Ubuntu where Docker is already installed): - -``` -docker build -t finesse-backend . -``` - -test locally: - -``` -export PORT= -docker run -p $PORT:$PORT -e PORT=$PORT --env-file .env finesse-backend -``` +Refer to the [infrastructure repository](https://github.com/ai-cfia/infra) for a Kubernetes deployment. The secrets (in this case environment variables) are managed with Hashicorp Vault. \ No newline at end of file diff --git a/docs/USAGE.md b/docs/USAGE.md index 7d0e0eb..3d073d0 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -1,24 +1,56 @@ -## Running and testing the API -Create and set the environment variables based on `.env.template`. +# Running and testing the API locally + +## With your local environment + +Create and set the environment variables based on `.env.template`. You will need to create a `.env` file. Running: -``` +```bash flask run -h 0.0.0.0 --debug ``` Alternatively, set the `FINESSE_BACKEND_DEBUG_MODE` environment variable to -`True` and -run: -``` +`True` and run: + +```bash python run.py ``` -Query from the command-line: +## With docker + +Create and set the environment variables based on `.env.template`. You will need to create a `.env` file. + +Build the container: + +```bash +docker build -t finesse-backend . +``` + +Deploy the container locally: +```bash +docker run -p 5000:5000 -e PORT=$PORT --env-file .env finesse-backend ``` -curl -X POST http://localhost:5000/search --data '{"query": "is e.coli a virus -or bacteria?"}' -H "Content-Type: application/json" + +## Check if the API is working properly + +Test the path: `/search/static` + +```bash +curl -X POST http://localhost:5000/search/static --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json" +``` + +Test the path: `/search/azure` + +```bash +curl -X POST http://localhost:5000/search/azure --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json" +``` + +Test the path: `/search/ailab` + +```bash +curl -X POST http://localhost:5000/search/ailab --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json" ``` JSON structure explanation: @@ -30,4 +62,4 @@ JSON structure explanation: - title: The title of the document. - content: The main content or body of the document. - subtitle: The title or titles extracted from the snippet. -- last_updated: The last modified date of the document. +- last_updated: The last modified date of the document. \ No newline at end of file