Open palfrey opened 7 months ago
Same for me here! I was caught in this trap yesterday.
Thanks @palfrey for reporting. I was able to confirm the behaviour you're describing. The main issue to me here seems not properly handling the missing DockerContext during sam build
since it doesn't end up building any images. I will mark it as a bug for the team to prioritize.
Looking at this again, I don't necessarily think that it's a bug. During a single build, SAM CLI will build all the functions in the template. This can include functions that have a DockerContext
and some that don't. When running sam build --debug
the following message would be seen if a function is missing the DockerContext
field:
Skip Building HelloWorldFunction function, as it is missing either Dockerfile or DockerContext metadata properties.
While I understand that this behaviour might be confusing, changing it now to error out when encountering a function without the DockerContext
could break existing customers utilizing this behaviour. One thing we might be able to do here to make things more clear is to change that message from being debug
level to info
level.
Description:
If you set
Dockerfile
in a function's metadata, but notDockerContext
,sam build
seems to just work, except thensam local invoke
complainsError: ImageUri not provided for Function: YourFunctionName of PackageType: Image
which is very confusing. Note alsosam validate
doesn't complain abou this.Steps to reproduce:
Create a correct docker image SAM template, then remove just the
DockerContext
metadata param.Observed result:
sam local invoke
fails with a confusing errorExpected result:
sam validate
fails, or maybesam build
?Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.116.0