paketo-buildpacks / dotnet-core

A Cloud Native Buildpack for .NET Core
Apache License 2.0
45 stars 4 forks source link

DotNet Published app with 'self-contained' command and try to deploy with the Packeto buildpack from windows machine, deployment is getting failed. #1089

Closed mukeshcpande closed 2 months ago

mukeshcpande commented 3 months ago

What happened? Published the dotnet app with target framework 6 with the following command dotnet publish "C:\gitRepo\SampleAsp\SampleAsp.csproj" -c release --self-contained -r linux-x64 --output "C:\gitRepo\SampleAsp\output"

After publish when deploying the app getting following error as

16:54:31.11-0500 [STG/] OUT paketo-buildpacks/icu 0.7.7 2024-03-18T16:54:31.11-0500 [STG/] OUT paketo-buildpacks/dotnet-execute 0.14.29 2024-03-18T16:54:31.11-0500 [STG/] OUT Timer: Detector ran for 44.385842ms and ended at 2024-03-18T21:54:31Z 2024-03-18T16:54:31.95-0500 [STG/] OUT Warning: No cached data will be used, no cache specified. 2024-03-18T16:54:31.95-0500 [STG/] OUT Timer: Restorer started at 2024-03-18T21:54:31Z 2024-03-18T16:54:31.95-0500 [STG/] OUT Timer: Restorer ran for 127.492µs and ended at 2024-03-18T21:54:31Z 2024-03-18T16:54:33.43-0500 [STG/] OUT Timer: Builder started at 2024-03-18T21:54:33Z 2024-03-18T16:54:33.44-0500 [STG/] OUT 2024-03-18T16:54:33.44-0500 [STG/] OUT Paketo Buildpack for CA Certificates 3.6.8 2024-03-18T16:54:33.44-0500 [STG/] OUT https://github.com/paketo-buildpacks/ca-certificates 2024-03-18T16:54:33.44-0500 [STG/] OUT Launch Helper: Contributing to layer 2024-03-18T16:54:33.44-0500 [STG/] OUT Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper 2024-03-18T16:54:33.46-0500 [STG/] OUT Paketo Buildpack for ICU 0.7.7 2024-03-18T16:54:33.46-0500 [STG/] OUT Resolving ICU version 2024-03-18T16:54:33.46-0500 [STG/] OUT Candidate version sources (in priority order): 2024-03-18T16:54:33.46-0500 [STG/] OUT -> "" 2024-03-18T16:54:33.46-0500 [STG/] OUT 2024-03-18T16:54:33.46-0500 [STG/] OUT Selected ICU version (using ): 74.2 2024-03-18T16:54:33.46-0500 [STG/] OUT 2024-03-18T16:54:33.46-0500 [STG/] OUT Executing build process 2024-03-18T16:54:33.46-0500 [STG/] OUT Installing ICU 2024-03-18T16:54:34.22-0500 [STG/] OUT Completed in 762ms 2024-03-18T16:54:34.22-0500 [STG/] OUT 2024-03-18T16:54:34.22-0500 [STG/] OUT Generating SBOM for /layers/paketo-buildpacks_icu/icu 2024-03-18T16:54:34.22-0500 [STG/] OUT Completed in 0s 2024-03-18T16:54:34.22-0500 [STG/] OUT 2024-03-18T16:54:34.24-0500 [STG/] OUT Paketo Buildpack for .NET Execute 0.14.29 2024-03-18T16:54:34.24-0500 [STG/] OUT Generating SBOM for /workspace 2024-03-18T16:54:34.28-0500 [STG/] OUT Completed in 36ms 2024-03-18T16:54:34.28-0500 [STG/] OUT 2024-03-18T16:54:34.28-0500 [STG/] OUT Assigning launch processes: 2024-03-18T16:54:34.28-0500 [STG/] OUT SampleAsp (default): /workspace/SampleAsp 2024-03-18T16:54:34.28-0500 [STG/] OUT 2024-03-18T16:54:34.31-0500 [STG/] OUT Timer: Builder ran for 873.043637ms and ended at 2024-03-18T21:54:34Z 2024-03-18T16:54:37.15-0500 [STG/] OUT Warning: No cached data will be used, no cache specified. 2024-03-18T16:54:37.36-0500 [STG/] OUT Timer: Exporter started at 2024-03-18T21:54:37Z 2024-03-18T16:54:37.39-0500 [STG/] OUT Adding layer 'paketo-buildpacks/ca-certificates:helper' 2024-03-18T16:54:37.65-0500 [STG/] OUT Adding layer 'paketo-buildpacks/icu:icu' 2024-03-18T16:54:38.89-0500 [STG/] OUT Adding layer 'paketo-buildpacks/dotnet-execute:port-chooser' 2024-03-18T16:54:38.96-0500 [STG/] OUT Adding layer 'buildpacksio/lifecycle:launch.sbom' 2024-03-18T16:54:42.62-0500 [STG/] OUT Adding 1/1 app layer(s) 2024-03-18T16:54:42.69-0500 [STG/] OUT Adding layer 'buildpacksio/lifecycle:launcher' 2024-03-18T16:54:42.83-0500 [STG/] OUT Adding layer 'buildpacksio/lifecycle:config' 2024-03-18T16:54:42.83-0500 [STG/] OUT Adding layer 'buildpacksio/lifecycle:process-types' 2024-03-18T16:54:42.83-0500 [STG/] OUT Adding label 'io.buildpacks.lifecycle.metadata' 2024-03-18T16:54:42.83-0500 [STG/] OUT Adding label 'io.buildpacks.build.metadata' 2024-03-18T16:54:42.83-0500 [STG/] OUT Adding label 'io.buildpacks.project.metadata' 2024-03-18T16:54:42.83-0500 [STG/] OUT Setting default process type 'SampleAsp' 2024-03-18T16:54:42.83-0500 [STG/] OUT Timer: Saving harbor.dell.com/pcf-images/korifi/kob/d32428c9-a580-481e-addb-4120701596be-droplets... started at 2024-03-18T21:54:42Z 2024-03-18T16:54:45.32-0500 [STG/] OUT *** Images (sha256:396b002694907ea1a79a5448ead1948651616089632b0f210fc6fe1bb9aaae9a): 2024-03-18T16:54:45.32-0500 [STG/] OUT harbor.dell.com/pcf-images/korifi/kob/d32428c9-a580-481e-addb-4120701596be-droplets 2024-03-18T16:54:45.32-0500 [STG/] OUT harbor.dell.com/pcf-images/korifi/kob/d32428c9-a580-481e-addb-4120701596be-droplets:b1.20240318.215420 2024-03-18T16:54:45.32-0500 [STG/] OUT Timer: Saving harbor.dell.com/pcf-images/korifi/kob/d32428c9-a580-481e-addb-4120701596be-droplets... ran for 2.486000673s and ended at 2024-03-18T21:54:45Z 2024-03-18T16:54:45.32-0500 [STG/] OUT Timer: Exporter ran for 7.953359261s and ended at 2024-03-18T21:54:45Z 2024-03-18T16:54:46.40-0500 [STG/] OUT Build successful 2024-03-18T16:55:09.82-0500 [APP/] OUT Setting ASPNETCORE_URLS=http://0.0.0.0:8080/ 2024-03-18T16:55:09.83-0500 [APP/] OUT ERROR: failed to launch: path lookup: exec: "/workspace/SampleAsp": permission denied

What you expected to happen Contents from the publish directory for the dotnet app should get deployed successfully and run without any crash along with the permission issue.

Acceptance Criteria GIVEN : Build and Publish 'self-contained', when deploying the app WHEN I : After deployment start of the app THEN I : Crash with the permission denied error

How to reproduce it (as minimally and precisely as possible) Create any sample hello world app, build and publish per above given command and deploy the contents of the output directory in the container.

Able to create the DotNet app in Ubuntu followed by the successful deployment. However if we compare CF versus Packeto buildpacks We're able to run following command followed by successful app deployment from the windows machine with the help of CF DotNet core buildpack.

dotnet publish -c release --self-contained -r linux-x64

However if we try the same above command to publish the app image and try to deploy with the Packeto buildpack from windows machine, deployment is getting failed.

What is the difference between buildpacks where one is working fine after publish from the windows/linux machine and other one is unable to work.

sophiewigmore commented 3 months ago

Hey @mukeshcpande, I just want to check - were you able to build the same app successfully when running the dotnet publish step from a Linux machine, rather than Windows? I want to make sure this is definitely a Windows issue, since I cannot reproduce this on my Linux machine.

With the Paketo buildpacks, the /workspace directory cannot be written to during the build at all (unlike CF buildpacks) which is a difference for sure. However, it seems like you're hitting an issue at run-time, rather than during the build.

When you run the app, can you do the following test?

docker run -it --entrypoint launcher <YOUR APP NAME> ls -al

and paste the results here? I'm specifically interested in seeing the file permissions on the SampleAsp file. When I run this scenario locally, the file permissions of interest are -rwxr-xr-x.

sophiewigmore commented 3 months ago

I'm also curious if your build works if you just try to build your source application with the buildpacks instead of building it as a self-contained app. By this I mean, running the buildpack build on the source app before you run dotnet publish. Just curious to pinpoint where the issue comes from

mukeshcpande commented 3 months ago

Hey @mukeshcpande, I just want to check - were you able to build the same app successfully when running the dotnet publish step from a Linux machine, rather than Windows? I want to make sure this is definitely a Windows issue, since I cannot reproduce this on my Linux machine.

With the Paketo buildpacks, the /workspace directory cannot be written to during the build at all (unlike CF buildpacks) which is a difference for sure. However, it seems like you're hitting an issue at run-time, rather than during the build.

When you run the app, can you do the following test?

docker run -it --entrypoint launcher <YOUR APP NAME> ls -al

and paste the results here? I'm specifically interested in seeing the file permissions on the SampleAsp file. When I run this scenario locally, the file permissions of interest are -rwxr-xr-x.

Hey @sophiewigmore, from the Linux machine able to build and publish the app with the following parameters and with that app is running fine without any issue. dotnet publish --configuration Release --self-contained true --runtime linux-x64

However issue happens if the app is published using above parameters from the windows machine.

Refer following screeshots for the file accessibility of the apps deployed with the self-contained mode true

image

mukeshcpande commented 3 months ago

I'm also curious if your build works if you just try to build your source application with the buildpacks instead of building it as a self-contained app. By this I mean, running the buildpack build on the source app before you run dotnet publish. Just curious to pinpoint where the issue comes from

If I run the following command to publish the app in windows machine,

dotnet publish -c release --self-contained false

With the above command app is getting deployed successfully and working as expected in the Linux container.

sophiewigmore commented 2 months ago

Thank you for the details @mukeshcpande. I don't think that building on Windows then running on Linux is a workflow we support in the Paketo space. I don't think we make any claims about Windows support here in the same way it was in CF. While it's a strange issue, I'm not that surprised it's not working, considering this isn't a case we officially support and the run-image user doesn't have permissions.

mukeshcpande commented 2 months ago

Closing as windows case is not officially supported and DotNet app should be build and published as self-contained (true) mode in the Linux machine only to run the app successfully.