question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deployment is *very* slow (nodeJS with publish profile)

See original GitHub issue

I’m using a workflow file adapted from “build and deploy a Node.js Web app to Azure using publish profile”.

(side remark) : I had issues with symbolic links too (see https://github.com/Azure/webapps-deploy/issues/54#issuecomment-694259266)

Upon analysis, it seems that the whole copy of the node_modules folders to the webroot of the webapp takes ages (10-12 minutes for the Azure Webapp deploy step !) It’s very inefficient to process and send many little files over network.

=> Shouldn’t the final npm install (and npm run build – I’m using typescript) commands be executed on the target machine instead of a github action container ?

IMHO, the workflow should be like this for the “nodeJS with publish profile” scenario :

  • the github action should only send source files to the targeted runtime machine
  • npm install, npm run build and npm start should be done on the targeted runtime machine
  • It’s up to the developer to ensure that is app is building correctly before calling azure/webapps-deploy

Related questions :

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:34
  • Comments:72 (7 by maintainers)

github_iconTop GitHub Comments

17reactions
danmanacommented, Dec 28, 2021

The workflow described above runs in ~10 minutes, out of which the deploy part is the longest.

On my second attempt, I configured the workflow to deploy and run from ZIP, which is much faster - total time ~3 minutes (~1:45s build, ~30s deploy)

Step 1, in Azure configure the app to run from package, and disable the Oryx build (Github actions builds everything anyway)

WEBSITE_RUN_FROM_PACKAGE=1
SCM_DO_BUILD_DURING_DEPLOYMENT=false

Step 2, use this Github workflow that creates a zip after build (including node_modules)

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Node.js version
        uses: actions/setup-node@v2
        with:
          node-version: '16'
          cache: 'npm'

      - name: npm install, build, and test
        run: |
          npm install
          npm run build --if-present
          npm run test:ci --if-present

      # Zip artifacts to speed things up
      - name: Zip artifact for deployment
        run: zip release.zip ./* -qr

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v2
        with:
          name: node-app
          path: release.zip

  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@v2
        with:
          name: node-app

      - name: 'Deploy to Azure Web App'
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'my-app'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_38C3A64C5A4A49F792EA62F5DCBC13ED }}
          package: release.zip

An added benefit to this method is that you can download the Action artifacts later if you need to reproduce the environment exactly for debugging, as the Github job artifact named node-app here is exactly what is running on the server. There is no chance that the server would download a newer npm version or anything like that.

Plus it might reduce cold starts

12reactions
kavermacommented, Mar 17, 2021

@sfabriece you can provide directly zip as a input to action or folder location which will be zipped in action

- name: 'Run Azure webapp deploy action using publish profile credentials'
      uses: azure/webapps-deploy@v2
      with:
        app-name: <app-name>
        publish-profile: ${{ secrets.azureWebAppPublishProfile }}
        package: <provide path of your folder or zip file>

Closing the issue as the question has been addressed and for performance we already have npm install in the sample workflow which optimises the time

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to substantially slow down your Node.js server
We ran the load tests for both staging deployments concurrently in order to simulate identical running conditions, because the data sources that ...
Read more >
This is why your Node.js application is slow
The simple problem with it is that it is capable of slowing down your application greatly when not correctly used. Whenever a promise...
Read more >
Very slow deploy for simple node js app on free tier - Render
I noticed that deploys for the free tier are extremely slow. It could take between 30 seconds to 1 minutes on the Heroku...
Read more >
Very slow Kudu deployments on Azure Websites
I suspect that with mention of nodejs, there are a bunch of npm packages being ... Look at your publish profile if you...
Read more >
Profile slow code in Node.js - IBM Developer
While profiling, your application may take a slight performance hit, so keep ... true let profile try { await post('Profiler.enable') await ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found