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

Bake: Define project name and support COMPOSE_PROJECT_NAME in Yaml #1161

Open
ciaranmcnulty opened this issue Jun 12, 2022 · 2 comments
Open

Comments

@ciaranmcnulty
Copy link

ciaranmcnulty commented Jun 12, 2022

The compose spec section about project names says:

[the project name] MUST be exposed for interpolation and environment variable resolution as COMPOSE_PROJECT_NAME

This would be pretty handy for one of my projects (to use as a tagging prefix)

Bake doesn't really have a way to define or compute the project name that I can see (I guess as it's not used for anything?) but it' suffice for me to read it from the name: top level element

name: foo

services:
  myservice:
    build:
      x-bake:
        tags:
          - "${COMPOSE_PROJECT_NAME}"

Would be:

"target": {
    "myservice": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "tags": [
        "foo"
      ]
    }
  }
@ciaranmcnulty
Copy link
Author

Note that compose doesn't do this correctly yet

@dm17
Copy link

dm17 commented Apr 21, 2023

Is buildx not meant to match the features of docker and compose in order to extend them? I can't seem to get this working via buildx from a Dockerfile:
FROM baseimg-${project}:latest AS stage2-app

Because project (in compose build args:) and compose_project_name don't register for buildx. Is there another way to do env var aware multi-layer builds with buildx. I would love to use compose, however I can't because of this: #175
Which suggests the only real work around is using buildx (via sudo docker buildx create --driver-opt network=). It is a game of cat and mouse with build-time networking!

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