aws / aws-extensions-for-dotnet-cli

Extensions to the dotnet CLI to simplify the process of building and publishing .NET Core applications to AWS services
Apache License 2.0
369 stars 87 forks source link

Serverless MetaData / DockerBuildArgs are not being sent as --build-arg to docker #201

Closed danyhoron closed 2 years ago

danyhoron commented 2 years ago

Description

I have a serverless json file to deploy a .net 6 lambda function. I configured my Dockerfile to accept some build arguments. In the serverless metadata section I have the following config:

{
  "Metadata": {
    "Dockerfile": "Dockerfile",
    "DockerContext": ".",
    "DockerTag": "",
    "DockerBuildArgs": {
      "PROJECT_PATH": "/src/path-to/project",
      "PROJECT_FILE": "project.csproj"
    }
  }
}

when I run: dotnet lambda deploy-serverless -t serverless.json --profile <my-profle> -sb <my-s3-bucket> -sn <my-stack-name> I get the logs below. --build-arg is missing from the docker build command

Reproduction Steps

Logs

... invoking 'docker build', working folder '/Users/<redacted>/Work/Development/my-project/., docker file /Users/<redacted>/Work/Development/my-project/Dockerfile, image name my-project:latest'
... docker build -f "/Users/<redacted>/Work/Development/my-project/Dockerfile" -t myproject:latest .

Environment

Resolution


This is a :bug: bug-report

ashishdhingra commented 2 years ago

Could be related to https://github.com/aws/aws-extensions-for-dotnet-cli/issues/198.

danyhoron commented 2 years ago

It behaves the same on 5.2.0 and on 5.1.4

ashishdhingra commented 2 years ago

It behaves the same on 5.2.0 and on 5.1.4

@danyhoron Please advise if it was working in any of the earlier versions. If not, then this is most likely a feature request.

danyhoron commented 2 years ago

I couldn't find any official documentation on the Metadata property. I only tried it on those two versions. I don't know about older versions.

ashishdhingra commented 2 years ago

DockerCLIWrapper supports passing additional options to the docker build. Not sure if this is similar to DockerBuildArgs. SAM: Building applications specifies DockerBuildArgs as the supported metadata parameter. SAM CLI code expects it to be of type dictionary. Refer Set build-time variables (--build-arg).

This appears to be a feature request. Needs discussion with the team.

ashishdhingra commented 2 years ago

Discussed with the team. Good candidate for feature request.

Just for reference: https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/src/Amazon.Lambda.Tools/TemplateProcessor/TemplateProcessorManager.cs#L289

ashishdhingra commented 2 years ago

Support for DockerBuildArgs is released in Amazon.Lambda.Tools version 5.4.3.

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.