Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet eb deploy-environment not setting the Procfile web startup properly #285

Open
ddivita opened this issue Jul 14, 2023 · 10 comments
Open
Labels
bug This issue is a bug. module/cli-ext p2 This is a standard priority issue queued

Comments

@ddivita
Copy link

ddivita commented Jul 14, 2023

Describe the bug

I will preface this by saying this could be a GitLab pipeline issue, however, I have also seen this happen on a local development machine.

Command:

dotnet eb deploy-environment --application $EB_APPLICATION_NAME --environment $EB_ENVIRONMENT_NAME --version-label $CI_COMMIT_SHA-$CI_JOB_STARTED_AT --self-contained true --region $AWS_DEFAULT_REGION

GitLab script:

api_deploy_job:
  stage: deploy
  image: mcr.microsoft.com/dotnet/sdk:7.0
  only:
    - develop
  script:
    - echo $CI_COMMIT_SHA
    - echo $AWS_DEFAULT_REGION 
    - apt-get update && apt-get install -y unzip
    - apt-get install -y zip   
    - apt-get update
    - apt-get install -y awscli
    - dotnet --version
    - aws --version
    - dotnet tool install -g Amazon.ElasticBeanstalk.Tools
    - export PATH="$PATH:/root/.dotnet/tools"
    - cd HP.Api         
    - dotnet eb deploy-environment --application $EB_APPLICATION_NAME --environment $EB_ENVIRONMENT_NAME --version-label $CI_COMMIT_SHA-$CI_JOB_STARTED_AT --self-contained true --region $AWS_DEFAULT_REGION

The script initiates the dotnet publish command:

dotnet publish "/builds/hp-services/HP.Api" --output "/builds/hp-services/HP.Api/bin/Release/net7.0/publish" --configuration "Release" --framework "net7.0"  --runtime linux-x64 --self-contained true

After the publish compiles the project and creates the files, the Procfile is auto-generated. The issue is the Procfile is not setting the proper startup web assembly.
image

Expected Behavior

Running the same command on a local environment produces this Procfile:
image

Current Behavior

The auto-generated Procfile is pointing to the wrong assembly. It's not always the same assembly either, but it never picks the API assembly. Even when the Procfile is created manually, it still does not deploy properly.

Reproduction Steps

I'm not 100% sure what might be going on, but I have a Minimal API that is also referencing an MS Test project. I'm not sure that is the issue since I can run the commands locally without issue. It could be the docker image used for the deployment.

I have another minimal API project that deploys fine in GitLab and locally. This project has no references to any other projects.

Possible Solution

I tried creating a Procfile that is set to Copy Always in the root of the API project. This does not work locally or in the pipeline.

Contents of the Procfile

web: ./HP.Api

This is in the logs, which makes sense:
image

However, the instance does not deploy properly:
image

Additional Information/Context

No response

Targeted .NET platform

.Net 7

CLI extension version

AWS CLI:
aws-cli/1.19.1 Python/3.9.2 Linux/5.4.109+ botocore/1.20.0

Donet EB:
dotnet-eb Tool 'amazon.elasticbeanstalk.tools' (version '4.3.2') was successfully installed

GitLab Runner:

Running with gitlab-runner 16.1.0~beta.59.g83c66823 (83c66823)
  on blue-3.saas-linux-small-amd64.runners-manager.gitlab.com/default zxwgkjAP, system ID: s_d5d3abbdfd0a
  feature flags: FF_USE_IMPROVED_URL_MASKING:true
Preparing the "docker+machine" executor

Using Docker executor with image mcr.microsoft.com/dotnet/sdk:7.0 ...
Pulling docker image mcr.microsoft.com/dotnet/sdk:7.0 ...

Environment details (OS name and version, etc.)

linux

@ddivita ddivita added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 14, 2023
@ashishdhingra
Copy link
Contributor

Hi @ddivita,

Good morning.

Based on initial high level look, I'm not sure if the Procfile is a .NET Core application compilation/publish concept. Based on the below articles, it appears to be Linux concept not specific to .NET:

So just curious on how in your case, the Procfile is auto-generated. Also if you are manually crafting Procfile, you might want to set it to relative path of .NET assembly (e.g. web: dotnet ./dotnet-core-app1/dotnetcoreapp1.dll) as documented in the 1st link above.

Unsure if this is the AWS .NET CLI extensions issue since Procfile creation is probably not handled by our tooling, and its process by ElasticBeanstalk environment.

CC @normj

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Jul 14, 2023
@ddivita
Copy link
Author

ddivita commented Jul 14, 2023

@ashishdhingra The Procfile is definitely being auto-generated by something ;). I can see the file in the zipped code and looks exactly like the example I set manually.

image

@ashishdhingra
Copy link
Contributor

ashishdhingra commented Jul 14, 2023

@ashishdhingra The Procfile is definitely being auto-generated by something ;). I can see the file in the zipped code and looks example like the example I set manually.

@ddivita Is it generated automatically locally when compiling under Visual Studio? If not, might be there is some step in your pipeline that generates it!

@ashishdhingra
Copy link
Contributor

@ashishdhingra The Procfile is definitely being auto-generated by something ;). I can see the file in the zipped code and looks exactly like the example I set manually.

@ddivita Looks like I found EBUtilities.SetupPackageForLinux() which uses the existing Procfile if found, else creates a new one with web: content here for Linux environment.

Could you please share the sample project for reproduction with folder structure for issue?

Thanks,
Ashish

@ashishdhingra ashishdhingra added needs-reproduction This issue needs reproduction. and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Jul 14, 2023
@ddivita
Copy link
Author

ddivita commented Jul 17, 2023

@ashishdhingra I think I see what might be going on. That method you posted led me to look at the runtimeconfig.json file. There are several, and that code picks the first file it sees which is why it may have been failing? I wonder if I only have 1 runtimeconfig if it would work properly.

Code:
image

Files in the .zip

image

@ddivita
Copy link
Author

ddivita commented Jul 17, 2023

@ashishdhingra I think I see what might be going on. That method you posted led me to look at the runtimeconfig.json file. There are several, and that code picks the first file it sees which is why it may have been failing? I wonder if I only have 1 runtimeconfig if it would work properly.

Code: image

Files in the .zip

image

This was the issue. I set the <GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles> for any project I didn't want the runtimeconfig.json to be generated. The deployment worked fine after this.

@ashishdhingra
Copy link
Contributor

@ashishdhingra I think I see what might be going on. That method you posted led me to look at the runtimeconfig.json file. There are several, and that code picks the first file it sees which is why it may have been failing? I wonder if I only have 1 runtimeconfig if it would work properly.
Code: image
Files in the .zip
image

This was the issue. I set the <GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles> for any project I didn't want the runtimeconfig.json to be generated. The deployment worked fine after this.

@ddivita Thanks for the findings and update. Please confirm if we are good to close this issue.

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-reproduction This issue needs reproduction. labels Jul 17, 2023
@github-actions
Copy link

This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 23, 2023
@ddivita
Copy link
Author

ddivita commented Jul 23, 2023

@ashishdhingra If this is by design, then this can be closed, however, what if there are multiple startup projects in a solution? This would always break it.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Jul 24, 2023
@ashishdhingra
Copy link
Contributor

@ashishdhingra If this is by design, then this can be closed, however, what if there are multiple startup projects in a solution? This would always break it.

@ddivita Thanks for your inputs. I will review this with team and get back to you.

@ashishdhingra ashishdhingra added needs-review p2 This is a standard priority issue queued and removed needs-review labels Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/cli-ext p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

2 participants