compose-spec / compose-spec

The Compose specification

Home Page:https://compose-spec.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for configuring additional build contexts

laurazard opened this issue · comments

What is the problem you're trying to solve

BuildKit added the --build-context argument to enable users to provide additional build contexts during a build. More documentation about this can be found here.

Describe the solution you'd like

Being able to configure additional build contexts in a Compose file, such as:

services:
  a:
    build:
      context: .
      build_contexts:
        - project=[a directory/image/etc.]

Used together with a Dockerfile such as:

# syntax=docker/dockerfile:1
FROM alpine:latest
COPY --from=project . /

Additional context
Add any other context about the feature request here.

We should just use contexts as this is in the build section already

Sounds good! I was wondering whether having contexts next to context would be confusing. I wonder if it should be extra_contexts or something similar to be more explicit that it's optional (as opposed to context). WDYT?

additional_contexts or named_contexts could indeed avoid confusion.
Also would probably better use of a mapping vs the name=path syntax introduced by buildx as a command line flag doesn't have much flexibility (we could support both, as we do in a few places already)