I have a GitHub repo that contains a client folder for the front-end and a server folder for the back-end at the root of the repo. We are deploying each of these two folders to their own azure web app within the same app service plan. I have a github action yaml file that deploys the contents of the server folder to the web app, but we would like to use absolute imports in our python backend (pylint and some other stuff seems to like that), so all of our imports look like from server.module import something which fails on azure because there is no server folder and the module folder is placed inside of whatever the default root folder on the web app server is. If we change that import to from module import something everything works.
What would be the best way to deploy this python app to the web app while still being able to use absolute imports? I'm assuming if we could throw everything inside of a server folder and change the startup command to reflect the new path of the app.py everything would work but getting the action to do this has proven difficult has been an issue. This is how my github action yaml currently looks:
on:
push:
branches:
- beta
paths:
- 'server/**'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
working-directory: ./server
- name: Install dependencies
run: pip install -r requirements.txt
working-directory: ./server
# Optional: Add step to run tests here (PyTest, Django test suites, etc.)
- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v4
with:
name: python-app
path: |
./server
!venv/
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: python-app
path: ./server
- name: Deploy web App using GH Action azure/webapps-deploy
uses: azure/webapps-deploy@v3
with:
app-name: <our_app_name>
slot-name: 'production'
publish-profile: ${{ secrets.BACKEND_PUBLISH_PROFILE }}
package: ./server```
from module import somethingimport pattern so everything is running fine. if we do thefrom server.module import somethingimport pattern we get the server module not found import error because the server folder doesn't exist