I have a Python web app on Azure that gets deployed via Github actions. I use the default deployment script that is created by the Azure deployment center (full script shown below). In order for my application to work, I must SSH into the deployment machine after each deployment and manually activate the virtual environment and install packages that aren’t available via pip.
Is there a way to include the manual installations in the pre-generated deployment script that Azure created for me?
These are the manual commands I must run when I SSH into the machine after every deployment…
source env/bin/activate sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
Here is the deployment script I’m currently using…
name: Build and deploy Python app to Azure Web App on: push: branches: - master jobs: build-and-deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: Set up Python version uses: actions/setup-python@v1 with: python-version: '3.6' - name: Build using AppService-Build uses: azure/appservice-build@v2 with: platform: python platform-version: '3.6' - name: 'Deploy to Azure Web App' uses: azure/webapps-deploy@v2 with: app-name: {{applicationname}} slot-name: {{slotname}} publish-profile: ${{ secrets.AzureAppService_PublishProfile_HIDDEN }}
Advertisement
Answer
If you really need to install more packages to the system than those installed by default, you’ll need to create your own docker image, publish it to your private Azure Registry and use them as in the example:
- uses: azure/docker-login@v1 with: login-server: contoso.azurecr.io username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - run: | docker build . -t contoso.azurecr.io/nodejssampleapp:${{ github.sha }} docker push contoso.azurecr.io/nodejssampleapp:${{ github.sha }} - uses: azure/webapps-deploy@v2 with: app-name: 'node-rnc' publish-profile: ${{ secrets.azureWebAppPublishProfile }} images: 'contoso.azurecr.io/nodejssampleapp:${{ github.sha }}'