Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a dotnet core app using AWS CodePipeline to ElasticBeanstalk

I'm trying to build a basic dotnet core application and deploy it using the default tool available to me in AWS. I currently have the following steps working:

  1. Repository in CodeCommit
  2. Checkin triggers CodeBuild build step on the Ubuntu image "aws/codebuild/dot-net:core-2.1" which runs the yml file(which creates the correct files I need to actually run the web app):

    version: 0.2
    
    phases:
    
    build:
    commands:
      - dotnet restore CMS/CMS.csproj
      - dotnet build CMS/CMS.csproj
      - dotnet publish CMS/CMS.csproj -o site
     artifacts:
      files:
        - CMS/site/**/*
        - CMS/aws-windows-deployment-manifest.json
    

aws-windows-deployment-manifest.json:

{
    "manifestVersion": 1,
    "deployments": {
        "aspNetCoreWeb": [{
                "name": "CMS",
                "parameters": {
                    "appBundle": "./site",
                    "iisPath": "/",
                    "iisWebSite": "Default Web Site"
                }
            }
        ]
    }
}
  1. CodeDeploy takes the artifacts and published them to an elastic beanstalk application configured to use windows. It's currently running the default application.

It runs through each step fine and I get green check marks throughout, but when I navigate to the EB instance the original site is still shown, showing me that my application hasn't been deployed. Is there something I'm missing?

I was really hoping I would be able to deploy an app from check in to finish without needing to modify a build environment, at least right now.

like image 865
HeWhoFreeks Avatar asked Nov 14 '18 00:11

HeWhoFreeks


1 Answers

Here is a buildspec.yml I wrote to create the beanstalk package from CodeBuild.

version: 0.2

phases:

  build:
    commands:
      - dotnet restore EbCiTest/EbCiTest.csproj
      - dotnet build EbCiTest/EbCiTest.csproj
      - dotnet publish EbCiTest/EbCiTest.csproj -o ./staging/app
      - cp ./EbCiTest/aws-windows-deployment-manifest.json ./EbCiTest/staging/.
artifacts:
  files:
    - '**/*'
  base-directory: 'EbCiTest/staging'

I think the trouble you are having is the zip file being created contains the full paths to the files so aws-windows-deployment-manifest.json is not at the root of the zip file. I suggest copying everything to a staging folder and then using that staging folder as the base-directory which will be the root of the zip file.

like image 91
Norm Johanson Avatar answered Oct 22 '22 18:10

Norm Johanson