question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle multiple prefixes with Bake

See original GitHub issue

Let’s say I have a Dockerfile like so:

FROM debian:latest AS debian

[...]


# debian is the default
FROM debian


FROM ubuntu:latest AS ubuntu

[...]


FROM alpine:latest AS alpine

[...]

And a docker-bake.hcl like so:

group "default" {
  targets = ["debian"]
}

group "all" {
  targets = ["debian", "ubuntu", "alpine", "centos"]
}

target "base" {
  context = "."
}

target "debian" {
  inherits = ["base"]
  target = "debian"
}

target "ubuntu" {
  inherits = ["base"]
  target = "ubuntu"
}

target "alpine" {
  inherits = ["base"]
  target = "alpine"
}

Any suggestions on how could I integrate the Metadata Action with the Bake Action so I would have tags generated with prefixes like:

my-image:latest # debian
my-image:debian
my-image:ubuntu
my-image:alpine

And of course, tagging with semver like my-image:alpine-1.1.0.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
sandhosecommented, Jan 21, 2022

I had this exact problem, and figured that the bake files are just JSON files that can be merged with jq. This is how I solved it, by running the action twice and merging the files:

https://github.com/matrix-org/matrix-authentication-service/blob/1df5cf42e32abaeedddc504afeb431d77154f78f/.github/workflows/check.yaml#L317-L345


     - name: Docker meta
       id: meta
       uses: docker/metadata-action@v3
       with:
         images: ...
         bake-target: docker-metadata-action
         tags: ...

     - name: Docker meta (debug variant)
       id: meta-debug
       uses: docker/metadata-action@v3
       with:
         images: ...
         bake-target: docker-metadata-action-debug
         tags: ...

     - name: Merge buildx bake files
       run: |
           jq -s '.[0] * .[1]' ${{ steps.meta.outputs.bake-file }} ${{ steps.meta-debug.outputs.bake-file }} > docker-bake.override.json

That way I have two different targets filled in my bake file: https://github.com/matrix-org/matrix-authentication-service/blob/1df5cf42e32abaeedddc504afeb431d77154f78f/docker-bake.hcl#L4-L6

1reaction
fourbytescommented, Sep 9, 2021

I’m trying to do something similar to this. I have a repo with multiple micro-services, each service is pushed to a registry (ghcr.io/<owner>/<project>/<service>:<tag>) and it doesn’t seem possible to use this metadata data action to set the tags for each service at the moment. I could do it with multiple steps however that would slow down the build as they’d have to run sequentially.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CakePHP Bake from different templates when using prefix
I want to different versions of all these templates when I bake with the admin prefix. I tried creating a Bake Theme.
Read more >
Routing - 4.x - CakePHP Cookbook
Multi word prefixes are by default converted using dasherize inflection, ie MyPrefix would be mapped to my-prefix in the URL. Make sure to...
Read more >
Can an English word have more than one prefix? - Quora
Yes. The English word formed can take different single prefixes to create such words as deformed, reformed ...
Read more >
Prefix-Suffix-Root List by Grade Level
(Generally, prefixes and suffixes change the meanings of roots, ... plural, more than one hats, pigs, boxes, wishes. Anglo-Saxon. -ing action/ process.
Read more >
The Toolbag Baking Tutorial - Marmoset
Toolbag's powerful GPU rendering engine is capable of handling very ... The Ignore Groups option will cast AO between different bake groups.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found