projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.
Apache License 2.0
3.12k stars 655 forks source link

Problem with zip deploy on linux for node application #3071

Closed Sobieck closed 4 years ago

Sobieck commented 4 years ago

We've been using zip deploy on linux for months successfully. There has been no change in how our pipeline works. Our last successful deploy with this pipeline was 10/15/2019. I believe the first time my build failed was 10/18/2019. I’m not sure though. All our changes lately have been very minor.

We build the node application on a windows instance in appveyor. It is zipped up using powershell and then deployed using zip deploy to a linux app service.

For some reason when kudu unzips the deployment zip it uses windows \ for directories. Then the kudu deployment script attempts to copy those files into the wwwroot folder and it can't. Here are the logs:

2019-10-29T11:59:41    Copying file: 'lib\ApplicationMappings.js.map'
2019-10-29T11:59:42    Copying file: 'lib\IHandler.d.ts'
2019-10-29T11:59:42    Copying file: 'lib\IHandler.js'
2019-10-29T11:59:42    Error: EINVAL: invalid argument, open '/home/site/wwwroot/lib\ApplicationMappings.d.ts'
2019-10-29T11:59:42    An error has occurred during web site deployment.
2019-10-29T11:59:42    Kudu Sync failed
2019-10-29T11:59:42 /opt/Kudu/Scripts/starter.sh "/home/site/deployments/tools/deploy.sh" 

Here is an image of the extracted folder:

image

The files not in directories copy to the wwwroot folder. The first file that is in a directory fails. I removed all the mapping files and type definitions while I was trying to figure this out. It just failed at the first .js file in a directory.

wwwroot after deployment failed:

image

I was able to deploy by stopping the node service, I used kudu bash to copy the zip file to the wwwroot folder from the /tmp/zipdeploy folder, then unzip the zipfile using the ‘unzip’ command, and then restarting the service. This worked, but it isn’t ideal.

suwatch commented 4 years ago

@sanchitmehta mind taking a look at this?

Sobieck commented 4 years ago

We ended up solving this problem by simply building the node app in a linux instance of appveyor and zipping it using bash. Everything unzips and deploys correctly now.

sarathkcm commented 4 years ago

I have the exact same problem. This has made deployments unreliable.

I use powershell on Windows to zip and deploy to a linux instance, and I keep getting the error:


  {
    "log_time": "2019-11-05T11:48:36.5265008Z",
    "id": "",
    "message": "Copying file: 'assets\\libraries\\styles\\toastify.min.css'",
    "type": 0,
    "details_url": null
  },
  {
    "log_time": "2019-11-05T11:48:36.5403084Z",
    "id": "",
    "message": "Error: EINVAL: invalid argument, open '/home/site/wwwroot/assets\\libraries\\js\\toastify-js.js'",
    "type": 0,
    "details_url": null
  },
{
    "log_time": "2019-11-05T11:48:36.5725687Z",
    "id": "",
    "message": "\\n/opt/Kudu/Scripts/starter.sh kudusync -v 50 -f /tmp/zipdeploy/extracted -t /home/site/wwwroot -n /home/site/deployments/5dfd905a2b95475dbbf671b7b600095d/manifest -p /opt/Kudu/Scripts/firstDeploymentManifest -i \".git;.hg;.deployment;.deploy.sh\"",
    "type": 2,
    "details_url": null
  }
sanchitmehta commented 4 years ago

@sarathkcm This is because PowerShell uses backward slash to encode the zip files. This used to previously work since we used .NET based Kudu on Mono which could interepret backward slashes. Typically, we recommend using a cross platform archive to zip the app to be deployed on Kudu on Linux which uses cross-platform forward slashes to encode the zip. One of the possible libraries you could use is 7zip .

sarathkcm commented 4 years ago

@sanchitmehta It works with 7-zip. Thank you.

harnoorDev commented 2 years ago

@sarathkcm This is because PowerShell uses backward slash to encode the zip files. This used to previously work since we used .NET based Kudu on Mono which could interepret backward slashes. Typically, we recommend using a cross platform archive to zip the app to be deployed on Kudu on Linux which uses cross-platform forward slashes to encode the zip. One of the possible libraries you could use is 7zip .

Thank you very much !! This saved me tons of time debugging