Feature request: AWS::Serverless::Function.ImageUri Should Also Accept a Local File Path
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Describe your idea/feature/enhancement
I wish SAM CLI would accept a local path to an image archive (the kind of thing which can be loaded by `docker image load`) for the value of `ImageUri`.
### Proposal
For an`ImageUri` containing a local path to an image archive, the command `sam build` would perform the equivalent of `docker image load` (in the same way that it will currently perform the equivalent of `docker image build`) and write the image name and tag into the built template as the new value of `ImageUri`.
The command `sam package` would do the same thing, but additionally perform the equivalent of the `docker image push` and write the address of the image in the remote repository into the output template as the new value of `ImageUri`.
In general, it would make `ImageUri` work a little more like `CodeUri`.
Things to consider:
1. _Will this require any updates to the [SAM Spec](https://github.com/awslabs/serverless-application-model)._ Yes, the `ImageUri` property would have to be documented to accept this kind of value.
2. _What if the archive is associated with multiple tags?_ If we have the taste for it, that could be an error. Alternatively, an action equivalent to `docker image import` could be performed instead, assigning a single canonical, generated name to the image in the same way as `sam build` does.
3. _Why would anyone want this?_ W-Well, I want this because my build system is capable of creating Docker images as file archives without the `docker` command-line tool or the docker service available. I know of other development teams who produce file archives of Docker images for scanning purposes. Lacking either end of Docker simplifies those steps in the CI process, so we only need to associate the docker-in-docker service with the job in which we perform `sam` commands for the final deployment. Also, it's much easier in many ways to manage CI artifacts which are normal files.
4. _Is this a thing that SAM CLI can possibly do?_ I admit I don't know for certain. `sam build` does its Docker work without the `docker` CLI tool available by using `docker+http://` URLs somehow. I _presume_ it's issuing commands to the Docker service over a more direct interface, and I see this capability in the Docker API, so it feels possible.
5. _Is there an alternative design?_ If overloading `ImageUri` like this is undesirable, I could imagine a property named `ImagePath` or `ImageArchive` or something similar to serve the same purpose.
### Additional Details
I would be willing to take on this work if this request is accepted. I've contributed to serverless-application-model and aws-sam-build-images before, so I probably wouldn't be _completely_ in over my head.
Contributor guide
Assessment
This issue has not been assessed yet.