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

output multiple images? #25

Open
kilpatty opened this issue Jan 22, 2020 · 2 comments
Open

output multiple images? #25

kilpatty opened this issue Jan 22, 2020 · 2 comments
Labels
frontend The core component rfc To discuss

Comments

@kilpatty
Copy link

Is there a way to allow this to output multiple images?

I'm using a workspace, but rather than output 2 binaries in the same image, I'd love to have this output 2 images each with one of the binaries.

If there is somewhere you can point me to implement this please do, I'm happy to spend the time!

@denzp
Copy link
Owner

denzp commented Jan 23, 2020

I wonder if the quick workaround works in your case:
docker build -f inner-crate-path/Cargo.toml .

In this case, the frontend will build only binary(-es) defined in a crate at inner-crate-path of the workspace.

There is a major drawback with this - unfortunately, you'll need to duplicate [package.metadata.wharf] annotations per each subcrate. The approach is also used by the cargo-wharf itself to produce 2 images out of a single workspace:
https://hub.docker.com/r/denzp/cargo-wharf-frontend
https://hub.docker.com/r/denzp/cargo-container-tools

@denzp
Copy link
Owner

denzp commented Jan 23, 2020

On the long run, I've been thinking about something similar to Cargo cfg(...). Eventually, it might be possible to specify base and "overridden" settings:

[package.metadata.wharf.builder]
image = "rust"

[package.metadata.wharf.output]
image = "debian:stable-slim"

[workspace.metadata.'cfg(name = binary-2)'.wharf.output] # <--
image = "ubuntu:latest"

[[package.metadata.wharf.binary]]
name = "binary-1"
destination = "/usr/local/bin/binary-1"

[[package.metadata.wharf.'cfg(name = binary-2)'.binary]] # <--
name = "binary-2"
destination = "/usr/local/bin/binary-2"

[[package.metadata.wharf.'cfg(name = binary-3)'.binary]] # <--
name = "binary-3"
destination = "/usr/local/bin/binary-3"

This suppose to always output binary binary-1, and optionally binary-2 and binary-3 depending on --build-arg cfg=name=binary-2 or --build-arg cfg=name=binary-3.

Additionally when --build-arg cfg=name=binary-2 is set, the output image should be overridden to ubuntu:latest.

What do you think about this proposal? Would this help for your use case?

@denzp denzp added this to the frontend-v0.1.0 milestone Jan 23, 2020
@denzp denzp added frontend The core component rfc To discuss labels Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend The core component rfc To discuss
Projects
None yet
Development

No branches or pull requests

2 participants