我在运行我的第一个基于AWS Lambda的无服务器项目时遇到了问题。我正在尝试使用本地主机上的SAM CLI运行API,但仍收到
Error: AspNetCoreFunction failed to build: COPY failed: file not found in build context or excluded by .dockerignore: stat bin/Release/lambda-publish: file does not exist在执行时
sam build --template .\serverless.template来自我的Catalog.API项目。我在阅读文档或在谷歌上搜索都找不到解决方案。请查看我的解决方案,网址为:https://github.com/RazorN/Serverless-aws-e-shop/tree/catalog-init
我的目标是使用"sam local start- API“运行localy api。
另外,请分享对我的解决方案架构或本地测试方法的任何想法,因为我说过这是我在使用微服务后第一次尝试无服务器架构。
感谢所有的回复:)
发布于 2021-10-09 21:25:23
或者添加到您的Catalog.API.csproj下一行:
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin/Release/lambda-publish</OutputPath>
</PropertyGroup>并以Release模式构建您的解决方案。
或者修复docker文件(Serverless-aws-e-shop/Services/Catalog/Catalog.API/Dockerfile)以从现有路径复制文件,或者使用多阶段构建在容器(as example dotnet docker app does)内构建解决方案
https://stackoverflow.com/questions/69510575
复制相似问题