diff --git a/.github/workflows/main_queryweaver.yml b/.github/workflows/main_queryweaver.yml index b42a3459..58d97375 100644 --- a/.github/workflows/main_queryweaver.yml +++ b/.github/workflows/main_queryweaver.yml @@ -88,5 +88,6 @@ jobs: id: deploy-to-webapp with: app-name: 'queryweaver' - slot-name: 'Production' + slot-name: 'production' startup-command: 'python -m uvicorn api.index:app --host 0.0.0.0 --port $PORT' + diff --git a/.github/workflows/staging_queryweaver(staging).yml b/.github/workflows/staging_queryweaver(staging).yml new file mode 100644 index 00000000..c8641711 --- /dev/null +++ b/.github/workflows/staging_queryweaver(staging).yml @@ -0,0 +1,93 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions +# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions + +name: Build and deploy Python app to Azure Web App - queryweaver + +on: + push: + branches: + - staging + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read #This is required for actions/checkout + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python version + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install pipenv + run: pip install pipenv + + - name: Install dependencies using make + run: make install + + - name: Build production assets + run: make build-prod + + - name: Generate requirements.txt for production + run: pipenv requirements > requirements.txt + + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v4 + with: + name: python-app + path: | + . + !venv/ + !node_modules/ + !.git/ + !test-results/ + !playwright-report/ + !tests/e2e/screenshots/ + !__pycache__/ + !Pipfile + !Pipfile.lock + !Makefile + + deploy: + runs-on: ubuntu-latest + needs: build + permissions: + id-token: write #This is required for requesting the JWT + contents: read #This is required for actions/checkout + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: python-app + + - name: Set up Python version + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_95C84156557F40AF875812F7C29CD989 }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_B26FFD333BD44EE98C7ACED0A22637B7 }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_DEEC4D371D1547A6A3F63C9FE22DF791 }} + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v3 + id: deploy-to-webapp + with: + app-name: 'queryweaver' + slot-name: 'staging' + startup-command: 'python -m uvicorn api.index:app --host 0.0.0.0 --port $PORT' + diff --git a/Dockerfile b/Dockerfile index daacc199..9dc12361 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Multi-stage build: Start with Python 3.12 base -FROM python:3.12-bookworm as python-base +FROM python:3.12-bookworm AS python-base # Main stage: Use FalkorDB base and copy Python 3.12 FROM falkordb/falkordb:latest @@ -50,6 +50,10 @@ RUN if [ -f ./app/package-lock.json ]; then \ echo "No frontend package.json found, skipping npm install"; \ fi +COPY ./app ./app + +RUN npm --prefix ./app run build + # Copy application code COPY . . diff --git a/Makefile b/Makefile index 64bf40d4..e43ce08f 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,6 @@ build-prod: npm --prefix ./app run build test: build-dev test-unit test-e2e ## Run all tests - - test-unit: ## Run unit tests only pipenv run python -m pytest tests/ -k "not e2e" --verbose @@ -63,10 +61,10 @@ clean: ## Clean up test artifacts find . -name "*.pyo" -delete run-dev: build-dev ## Run development server - pipenv run uvicorn api.index:app --host 127.0.0.1 --port $${PORT:-5000} --reload + pipenv run uvicorn api.index:app --host $${HOST:-127.0.0.1} --port $${PORT:-5000} --reload run-prod: build-prod ## Run production server - pipenv run uvicorn api.index:app --host 0.0.0.0 --port $${PORT:-5000} + pipenv run uvicorn api.index:app --host $${HOST:-0.0.0.0} --port $${PORT:-5000} docker-falkordb: ## Start FalkorDB in Docker for testing docker run -d --name falkordb-test -p 6379:6379 falkordb/falkordb:latest diff --git a/Pipfile b/Pipfile index 71a4fd0d..c73bad69 100644 --- a/Pipfile +++ b/Pipfile @@ -10,7 +10,7 @@ litellm = "~=1.75.9" falkordb = "~=1.2.0" psycopg2-binary = "~=2.9.9" pymysql = "~=1.1.0" -authlib = "~=1.4.0" +authlib = "~=1.6.2" itsdangerous = "~=2.2.0" jsonschema = "~=4.25.0" tqdm = "~=4.67.1" diff --git a/Pipfile.lock b/Pipfile.lock index 8caeee47..88dcab14 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "6f9d01cb33be5b25ca8c90bd03128ad64b3897d56f78dab33c218036bf0bdc8d" + "sha256": "d2c7a163fc8b815693ea1a28a742224f76804a0f40c582103b626482e45ff680" }, "pipfile-spec": 6, "requires": { @@ -150,12 +150,12 @@ }, "authlib": { "hashes": [ - "sha256:30ead9ea4993cdbab821dc6e01e818362f92da290c04c7f6a1940f86507a790d", - "sha256:edc29c3f6a3e72cd9e9f45fff67fc663a2c364022eb0371c003f22d5405915c1" + "sha256:2dd5571013cacf6b15f7addce03ed057ffdf629e9e81bacd9c08455a190e9b57", + "sha256:3bde83ac0392683eeef589cd5ab97e63cbe859e552dd75dca010548e79202cb1" ], "index": "pypi", "markers": "python_version >= '3.9'", - "version": "==1.4.1" + "version": "==1.6.2" }, "certifi": { "hashes": [ diff --git a/start.sh b/start.sh index 3e840cb9..e63fd68d 100644 --- a/start.sh +++ b/start.sh @@ -27,4 +27,4 @@ else fi echo "FalkorDB is up - launching FastAPI (uvicorn)..." -exec uvicorn api.index:app --host 0.0.0.0 --port 5000 $RELOAD_FLAG \ No newline at end of file +exec uvicorn api.index:app --host "${HOST:-0.0.0.0}" --port "${PORT:-5000}" $RELOAD_FLAG \ No newline at end of file