Skip to content

Feature request: ability to enable Docker Buildkit for sam build #3972

@ghost

Description

Describe your idea/feature/enhancement

I wish SAM CLI would enable me to enable Docker Buildkit when running sam build for a function with PackageType: Image.

This would enable me to use BuildKit features such as cache mounts for faster and more efficient builds.

Proposal

A very specific approach would be to add a new option along the lines of --use-docker-buildkit or something like that.

That said, something more general might be a good idea.

For example, I tried to enable buildkit by running export DOCKER_BUILDKIT=1 && sam build but it didn’t work.

IIRC docker build supports various other environment variables, so it might be a good idea to have a general purpose mechanism to set environment variables that’d be exposed to the docker build process.

One way to do this might be to simply forward/inherit the environment vars from the user’s shell to/into the docker build process.

Another way could be to add a CLI option like --docker-build-env DOCKER_BUILDKIT=1,FOO=bar

Additional Details

This will not require any updates to the SAM Spec.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions