-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
exporter: export multiple refs with local/image exporter #499
Conversation
|
||
func getPlatformArgs(bp, tp specs.Platform) []instructions.KeyValuePairOptional { | ||
m := map[string]string{ | ||
"BUILDPLATFORM": platforms.Format(bp), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add underscore prefixes to these reserved args?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to note is that these args are in no way "reserved". I think this can be introduced with no disruption to current users. These args do not leak the RUN
processes unless explicitly exposed with ARG
, like the current global args. If the user happens to use or wants to use an ARG
with the same name they can do that and it overrides the automatic values.
That being said we should, of course, get the names right so we don't need to change them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @thaJeztah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user happens to use or wants to use an ARG with the same name they can do that and it overrides the automatic values.
They can but they should not?
Maybe we should print warning, because people may use the same name accidentally without being aware of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually someone is already using ENV TARGETOS=.. TARGETARCH=..
in his/her own Dockerfile
https://raw.githubusercontent.com/ARwMq9b6/dnsproxy/master/cmd/dnsproxy/Dockerfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users should always get the behavior they expect. If these vars are used in the Dockerfile and user doesn't know about the automatic values and uses them as regular ones they will behave as regular ones. Only way the automatic behavior applies is if the Dockerfile author knows about the automatic behavior and uses these vars without passing in the values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the link, there is no behavior change. This Dockerfile will continue to work exactly like before.
To fill these vars automatically they would need to expose it as arg in a stage and not provide the value(eg. explicitly break the current behavior)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namespacing these will be tricky yes; not sure it underscores would work (esthetically, it feels ugly, but of course that's personal).
we're a bit limited because arg double as env vars, so (officially) dots aren't allowed, which could've been used for namespacing (then again, we don't want these names to become too long)
Separate from the namespacing discussion; wondering if they should be named TARGET_OS
and TARGET_ARCH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For TARGET_OS
, the current is similar to GOOS/GOARCH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm yeah 🤔
f1ea11d
to
fb31d5a
Compare
14c3bcd
to
3323f6f
Compare
ec6acd3
to
910a2f4
Compare
Added tests for the image and local exporters. Ready for review. |
@tiborvass Do you want to review this as well? |
ping @tiborvass |
exporter/containerimage/writer.go
Outdated
|
||
var p exptypes.Platforms | ||
if err := json.Unmarshal(platformsBytes, &p); err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors.Wrapf
exporter/containerimage/writer.go
Outdated
} | ||
|
||
refs := make([]cache.ImmutableRef, 0, len(inp.Refs)) | ||
layersMap := make(map[string]int, len(refs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len(refs) == 0
all the time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you meant len(inp.Refs)
@@ -242,6 +247,7 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State, | |||
} | |||
if d.base != nil { | |||
d.state = d.base.state | |||
d.platform = d.base.platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm not very familiar with this part, but just making sure we're not overwriting d.platform. Shouldn't this be under if d.platform == nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are inheriting from a stage you should also inherit the platform of that stage. I don't think any other case makes sense.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if i.meta == nil { | ||
i.meta = make(map[string][]byte) | ||
i.meta[k] = []byte(v) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be:
if i.meta == nil {
i.meta = make(map[string][]byte)
}
i.meta[k] = []byte(v)
? Same in the OCI one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided yes, or at least worthy of a PR: #558
Is there a list of the values of e.g. TARGETARCH somewhere?
The use case here is templating TARGETARCH into a URL that already uses |
@westurner I'm not sure what you mean by all possible values. There is no strict list. Eg. https://github.com/tonistiigi/wasm-cli-plugin uses |
When I specify A table with the most common outputs given the inputs in the docs would eliminate the need to run https://gist.github.com/sujaypillai/74d15e0d690a265a1b705cf3b26c6082#file-predefined_platform_arg with each platform value listed in the docs:
(Another related documentation issue: It's not clear (from the buildx docs) whether it's still necessary to specify |
No, based on https://github.com/containerd/containerd/blob/master/platforms/platforms.go#L86-L94 aarch64 is normalized to By running https://gist.github.com/sujaypillai/74d15e0d690a265a1b705cf3b26c6082#file-predefined_platform_arg you just see the values for one specific node and a specific
The difference is that buildx allows you to specify multiple values with |
Got it. Thanks!
…On Mon, Apr 27, 2020, 3:47 PM Tõnis Tiigi ***@***.***> wrote:
is there a platform variable with the value aarch64?
No, based on
https://github.com/containerd/containerd/blob/master/platforms/platforms.go#L86-L94
aarch64 is normalized to arm64. --platform=linux/arm64 means
TARGETARCH=arm64 . --platform=linux/aarch64 means TARGETARCH=arm64.
--platform=foo/bar means TARGETARCH=bar.
By running
https://gist.github.com/sujaypillai/74d15e0d690a265a1b705cf3b26c6082#file-predefined_platform_arg
you just see the values for one specific node and a specific --platform
value. As I said, there is no definitive list. If you add different nodes
and pass different --platform values you get different sets of output.
docker build --platform works now, correct?
The difference is that buildx allows you to specify multiple values with
--platform with container driver while docker build currently does not.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#499 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMNS7MDFN7FZJ73Z52D7LROXONXANCNFSM4FJKEVCA>
.
|
based on #496Add support for:
TARGETPLATFORM/BUILDPLATFORM
default ARG to Dockerfile moby#32487Example: