Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add the --builder flag support for build parameter for multi-arch builds #10664

Open
HarvyNBB opened this issue Jun 7, 2023 · 2 comments

Comments

@HarvyNBB
Copy link

HarvyNBB commented Jun 7, 2023

Description

  • Brief:
    Reference to the documentation
    Since it's possible to support multi-arch builds in docker-compose.yml,

Additionally reference to the documentation

In newer versions of Docker Desktop and Docker Engine, you’re using Buildx by default when you invoke the docker build command.

as a result, if the buildkit is enabled on the docker engine, then I assume docker compose build would use buildx

So during building simultaneous services with multi-arch there is a buildkit issue | buildx issue faced while trying to build multi arch builds for multiple services

Note: I'm not sure whether this is buildx issue or buildkit issue, so I created an issue for both

so in order to get over this issue it would be so beneficial for multi-arch builds if the builder could be either passed via a flag or defined in the docker-compose.yml
for e.g docker-compose.yml

Multiple services:

version: '3.7'

services:
 
  service_1:
    container_name: service_1-${VERSION}
    image: service_1:${VERSION}    
    build:
      context: .
      dockerfile: Dockerfile
      builder: test1
      platforms: 
        - ${PLATFORM_1}
        - ${PLATFORM_2}
  
  service_2:
    container_name: service_2-${VERSION}
    image: service_2:${VERSION}
    build:
      context: .
      dockerfile: Dockerfile
      builder: test2
      platforms: 
        - ${PLATFORM_1}
        - ${PLATFORM_2}

  service_3:
    container_name: service_3-${VERSION}
    image: service_3:${VERSION}
    build:
      context: .
      dockerfile: Dockerfile
      builder: test3
      platforms: 
        - ${PLATFORM_1}
        - ${PLATFORM_2}

commands to run

docker buildx create --name test1
docker buildx create --name test2
docker buildx create --name test3
docker compose build service_1 service_2 service_3 

Or for a single service

version: '3.7'

services:
 
  service_1:
    container_name: service_1-${VERSION}
    image: service_1:${VERSION}    
    build:
      context: .
      dockerfile: Dockerfile
      platforms: 
        - ${PLATFORM_1}
        - ${PLATFORM_2}
docker buildx create --name test1
docker compose build --builder test1 service_1 
@HarvyNBB HarvyNBB changed the title Feature: add the --builder flag support for build for multi-arch builds Feature: add the --builder flag support for build parameter for multi-arch builds Jun 7, 2023
@ndeloof
Copy link
Contributor

ndeloof commented Jun 7, 2023

We could indeed introduce builder, as a follow-up for compose-spec/compose-spec#233

@milas
Copy link
Member

milas commented Aug 31, 2023

Compose v2.20.0+ respects the BUILDX_BUILDER env var and also supports build --builder=my-builder.

Note that other commands that (might) perform builds like up and run do not support the --builder flag currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants