#Sharing Build Artifacts

1 messages · Page 1 of 1 (latest)

elder obsidian
#

Hi,

I am researching moving our team to Dagger from Earthly (which is unfortunately going away). One of the features we use a lot of is being able to share build artifacts across repositories. For example, we may have a build artifact in one repository that is needed during the build process of another. Earthly made this trivial by being able to reference the other repository and pull the artifact into the current build context.

Does Dagger have something similar to this?

lean rock
elder obsidian
#

We are using GitHub Actions. I’m not trying to store artifacts long term, just build them from one repo and bring them into the build context of another repo.

lean rock
elder obsidian
#

Would i be able to do the following:

  • Run Dagger to start a build for a Rust binary
  • During the build, build a dependent WASM module from another repository
  • Bundle the Rust binary and WASM module together into the final container
#

We don't really use GHA other than a nice UI for developers.

#

As an example, in Earthly we could do something like this:

IMPORT github.com/org/repo/wasm:v3.2.31 AS wasm

build:
  FROM somebase:latest

  COPY wasm+build wasm.module

Then running earthly +build would cause the WASM module from the remote repository to be built and stored in the current build context as wasm.module

#

I'm wondering if it's possible to get similar functionality in Dagger as a lot of our codebase is dependent in this way

#

The other reason we want to avoid GHA is because we want to keep Dagger's promise of "if it works locally, it works in CI." If we start adding custom GHA logic in builds, then developers can no longer reliably build locally.

Hope this makes sense.

lean rock
elder obsidian
#

We own both

lean rock
#

if you own this repository, the Dagger way to do this is via creating one module for each repository

#

so,you create a module in the "wasm" repo in your case with a function that returns the wasm.module *dagger.File

#

and then in the parent repo you do dagger install "url of wasm module repo" and that's pretty much it. Your parent's module will be able to call functions defined in your wasm module.

#

It's as if you were consuming any regular module from the Daggerverse (https://daggerverse.dev)

#

more info about that here: https://docs.dagger.io/api/remote-modules

Dagger supports the use of HTTP and SSH protocols for accessing remote repositories as Dagger modules, compatible with all major Git hosting platforms such as GitHub, GitLab, BitBucket, Azure DevOps, Codeberg, and Sourcehut. Dagger supports authentication via both HTTPS (using Git credential managers) and SSH (using a unified authentication appr...

#

LMK if you have any questions 🙌

elder obsidian
#

Ah, ok, that makes sense. Thanks! Does the install command do a global install or does it just add it to the local module?

I'm still a bit fuzzy on what constitutes a module. I'm hoping we can avoid having to have module source code in every single project in our monorepos. Can a module be as simple as the JSON config file?

lean rock
elder obsidian
#

Yes, I am head of the platform team, so that's more or less what I'm hoping to do in the longterm

#

The goal would be to avoid devs having to write their own builds unless their doing something truly off the beaten path

lean rock
#

In this model, if your central module has a dagger.Directory field or function argument, you can just pass a git repo as a reference for that

#

I think we have an example in the docs. Let me check it out

elder obsidian
#

So in that case, we wouldn't even necessarily have to have modules in every project? The CI could just call dagger run ... against a remote module and pass in the local code.

lean rock
#

dagger call -m $url $functionName

elder obsidian
#

Yeah, I saw that, just hadn't put together how to think about it from a more holistic standpoint. Appreciate your time in helping me wrap my head around it.

I think the last thing I'll need to figure out is chaining. With this more centralized (platform) approach, it's likely a specific task would require calling multiple modules in order to get the desire flow.

lean rock
#

It really depends on what APIs you want to expose to your devs

#

The best thing above all is that since everything is code, you have total control and flexibility about what you can express

#

There are other big teams following your same model. If you're looking for ideas and would like to get some feedback about your approach, I'd surely share that in #general

elder obsidian
#

Thanks, really appreciate your time and look forward to getting some prototype work done 🙂