aws / aws/aws-sam-cli

Enable support for multiple docker contexts

Open
#3,852 3 comments 3 reactions 0 assignees View on GitHub
area/build type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### 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](https://github.com/awslabs/serverless-application-model)

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.