如何使用 AWS CodePipeline 将 dotnet 核心应用程序部署到 ElasticBeanstalk [英] How to deploy a dotnet core app using AWS CodePipeline to ElasticBeanstalk
问题描述
我正在尝试构建一个基本的 dotnet 核心应用程序,并使用 AWS 中提供给我的默认工具进行部署.我目前正在执行以下步骤:
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:
- CodeCommit 中的存储库
Checkin 在 Ubuntu 映像aws/codebuild/dot-net:core-2.1"上触发 CodeBuild 构建步骤,该映像运行 yml 文件(它创建了我实际运行 Web 应用程序所需的正确文件):
- Repository in CodeCommit
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:
aws-windows-deployment-manifest.json:
{
"manifestVersion": 1,
"deployments": {
"aspNetCoreWeb": [{
"name": "CMS",
"parameters": {
"appBundle": "./site",
"iisPath": "/",
"iisWebSite": "Default Web Site"
}
}
]
}
}
- CodeDeploy 获取工件并将它们发布到配置为使用 Windows 的弹性 beantalk 应用程序.它当前正在运行默认应用程序.
它很好地完成了每一步,我得到了绿色的复选标记,但是当我导航到 EB 实例时,仍然显示原始站点,表明我的应用程序尚未部署.有什么我遗漏的吗?
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.
推荐答案
这是我编写的 buildspec.yml,用于从 CodeBuild 创建 beanstalk 包.
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'
我认为您遇到的问题是正在创建的 zip 文件包含文件的完整路径,因此 aws-windows-deployment-manifest.json 不在 zip 文件的根目录中.我建议将所有内容复制到暂存文件夹,然后将该暂存文件夹用作基目录,该目录将成为 zip 文件的根目录.
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.
这篇关于如何使用 AWS CodePipeline 将 dotnet 核心应用程序部署到 ElasticBeanstalk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!