Skip to content

Enable support for multiple docker contexts #3852

@mew1033

Description

@mew1033

Describe your idea/feature/enhancement

Docker just added support for multiple build contexts. This could be especially useful in multi-function lambda deployments where common code needs to be used across multiple functions. For example:

root_folder
├── function1
│   ├── function1_code.py
│   └── Dockerfile
├── function2
│   ├── function2_code.py
│   └── Dockerfile
├── common_libraries
│   └── common.py
├── samconfig.toml
└── template.yaml

In this scenario, it would be nice to have sam build effectively run docker build --build-context common=../common_libraries function1. Then all the Dockerfiles could be updated to pull the common libraries instead of having to copy common.py into each function's folder.

Proposal

Add support for multiple docker build contexts. Potentially through the DockerBuildArgs field in the template.

Things to consider:

  1. Will this require any updates to the SAM Spec

Additional Details

https://www.docker.com/blog/dockerfiles-now-support-multiple-build-contexts/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions