Home > front end >  AWS Serverless .NET Project local run with Docker image fails
AWS Serverless .NET Project local run with Docker image fails

Time:10-10

I have a problem running my first serverless project based on AWS Lambda. Im trying to run API using SAM CLI on localhost, still geting

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

while executing

sam build --template .\serverless.template

from my Catalog.API project. I can't find solution reading documentation or searching Google. Please check my solution placed at: https://github.com/RazorN/Serverless-aws-e-shop/tree/catalog-init

My goal is to run localy API using "sam local start-api"

Also, please share any thoughts about my solution architecture or local testing method, as I said it's my first attepmt to serverless architecture after working with microservices.

Thanks for any asnwers :)

CodePudding user response:

Either add to your Catalog.API.csproj next lines:

    <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
      <OutputPath>bin/Release/lambda-publish</OutputPath>
    </PropertyGroup>

And build your solution in Release mode.

Or fix your docker file (Serverless-aws-e-shop/Services/Catalog/Catalog.API/Dockerfile) to copy files from existing path or use multi-stage build to build your solution inside a container (as example dotnet docker app does)

  • Related