diff --git a/devcontainer/devcontainer.json b/.devcontainer/devcontainer.json similarity index 100% rename from devcontainer/devcontainer.json rename to .devcontainer/devcontainer.json diff --git a/.github/workflows/azure-deployment.yml b/.github/workflows/azure-deployment.yml new file mode 100644 index 0000000..cc0b351 --- /dev/null +++ b/.github/workflows/azure-deployment.yml @@ -0,0 +1,22 @@ +name: Azure Docker Deployment + +on: + push: + workflow_dispatch: + pull_request: + +jobs: + build: + uses: ai-cfia/github-workflows/.github/workflows/workflow-build-push-container-azure.yml@55-azure-workflow-deployment-missing + with: + container-name: ${{ github.event.repository.name }} + tag: ${{ github.sha }} + secrets: inherit + + deploy: + needs: build + uses: ai-cfia/github-workflows/.github/workflows/workflow-deploy-azure.yml@55-azure-workflow-deployment-missing + with: + container-name: ${{ github.event.repository.name }} + tag: ${{ github.sha }} + secrets: inherit diff --git a/Dockerfile b/Dockerfile index c5d1ddc..ef3d48b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -# Dockerfile -# Base image with Python 3.11 on Alpine -FROM python:3.11-alpine +# We chose Python 3.11 full variant as other variants lacks some tools necessary +# to build this project's dependencies +FROM python:3.11 # Establish /code as working directory in the container WORKDIR /code @@ -10,7 +10,8 @@ COPY ./requirements-production.txt requirements.txt RUN pip3 install --no-cache-dir -r requirements.txt # Copy source code into the working directory -COPY ./src . +COPY ./app ./app +COPY finesse-weights.json . # Use Gunicorn as the server, configuring it for the Flask app ENTRYPOINT gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 --forwarded-allow-ips "*" app:app diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index 0647fe9..fbd94e7 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -1,7 +1,8 @@ # Deployment ## Azure -Create and set the environment variables based on `.env.template`. Make sure `FINESSE_BACKEND_DEBUG_MODE` is not set to `True`. +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): @@ -12,5 +13,6 @@ docker build -t finesse-backend . test locally: ``` -docker run -p 5000:5000 -e PORT=5000 finesse-backend +export PORT= +docker run -p $PORT:$PORT -e PORT=$PORT --env-file .env finesse-backend ``` diff --git a/docs/USAGE.md b/docs/USAGE.md index ad2c92d..7d0e0eb 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -7,7 +7,8 @@ Running: flask run -h 0.0.0.0 --debug ``` -Alternatively, set the `FINESSE_BACKEND_DEBUG_MODE` environment variable to `True` and +Alternatively, set the `FINESSE_BACKEND_DEBUG_MODE` environment variable to +`True` and run: ``` python run.py @@ -16,7 +17,8 @@ python run.py Query from the command-line: ``` -curl -X POST http://localhost:5000/search --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json" +curl -X POST http://localhost:5000/search --data '{"query": "is e.coli a virus +or bacteria?"}' -H "Content-Type: application/json" ``` JSON structure explanation: