Skip to content

Session config file #9007

Closed
Closed

Description

@jedevc

This is something that has come up quite a bit recently, mostly in the context of #8800 (comment), but also around #8766 (comment).

Even when we have a way to configure engine settings, there are a collection of user configurations that would make sense to apply per client-session, without requiring a whole engine reload. For example:

  • Registry settings - today these are all only in the engine config, but it makes it very difficult to make changes (requiring an engine restart), and also you might want different settings per project you're on. It also means if you're using a shared engine, the shared engine has to be configured with potentially project-specific registries.
  • Build resources/limits (from Dagger build - resource requests/limits #4196) - for the same reasons.
  • Network configurations (including DNS, CAs, private git clones, etc).

I think we should have a different config file for these - it's annoying to have a different file, but the other alternatives don't feel right:

  • engine.json/engine.toml isn't the right place, since it's global to the engine.
  • dagger.json isn't the right place, since those are committed to git, and these settings are potentially machine specific - they might be committed to git, but they shouldn't need to be.
  • Config environment variables in the client session could work, but these are trickier to document and use (no .schema.json for example). Also more difficult to copy around and manage.
  • Explicit flags to every dagger command will end up very repetitive (and potentially even have confidential data then in the case of network configs).

So I'm proposing a dagger.settings.json (let the bikeshedding begin, no idea what the actual file should be). There are two potential places to load this from - one in ~/.config/dagger/dagger.settings.json, next to engine.json from #8800, and another next to dagger.json in your dagger module. We would try and load from both. This allows you to have machine specific, and also project specific session configs.

From the core-api POV, we could introduce a Engine.configure API, which would take optional args that would configure the entire session it's been made from (similar in style to Module.serve, it modifies session state).

Activity

  1. added
    area/engine
    on Nov 20, 2024
  2. grouville commented on Nov 20, 2024

    @grouville
    Member

    I suppose that this is where the user would reference the path to the mounting of the .gitconfig, for session-scoped git rewrite rules: #7787. Basically, the clean implementation to solve all those issues

  3. shykes commented on Dec 6, 2024

    @shykes
    Contributor
    1. Agree we need a config file for Dagger that is environment specific, in other words: not dagger.json, and not checked into the app repo. Somewhere in the home directory makes sense.

    2. Really not a fan of further splitting that into multiple files for multiple components, because: a) it's more concepts to learn for the user b) these concepts are mostly implementation details, c) the separation between components might actually move, eg. engine-wide config might shrink over time as we move more to the client. Then there's A config file for my modules #6323 ... would that go in yet another file? Much much better IMO to settle on a single filename and schema, and get on with it.

    TLDR: we need one config file for engine, session, and module defaults.

    A consequence of this is that yes, we will probably deprecate engine.json in the future (#8800) - we'll just move it to a field in a broader config schema.

  4. jedevc commented on Dec 7, 2024

    @jedevc
    ContributorAuthor

    I'm not sure I agree.

    There are 3 very distinct "types" of config, written by different "personas":

    • Module config. These settings belong only to the module, potentially A config file for my modules #6323. The module author probably writes these.
    • Engine config. These settings are tied to the lifetime of an engine, and aren't specific to a user (in the case of a shared engine). Things like garbage collection, or security configuration, etc) - when these are changed, the entire behavior of the engine can change (and probably requires restarting, or at least cancelling ongoing builds). The operator writes these - not all of these are possible to move to the client (or even desirable, since the operator may want to set these separately).
    • Client config. These settings are tied to the lifetime of a single dagger call/dagger shell session. And are written by the person who is actually using dagger (regardless of whether they're a module author, or an operator).

    I agree some of these might shift over time - but having just one config file makes more more complex dagger deployments significantly harder to manage, which is what this issue is attempting to solve (see #8766). The need is really to move away from just one config for everything, and to have it split up.

    If it's just one file, suppose I want a shared engine - with separate configs, my infra team can configure the gc and security of the engine, while my devs can configure the mirrors + network configuration - I think having one config file makes that hard, right?

    Potentially having one configuration file and allowing multiple copies could be a way forward? But I still think we then struggle to explain why some settings behave fundamentally differently than others - keeping those in another file helps clarify that.

    Edit: if we have a segmented config file with "module", "engine" and "client" keys, to larger config objects, I think that's actually probably okay (as long as we allow multiple configs). But we should definitely not mix top-level keys. I still think it's a bit easier to document and explain with separate config files - but I think I'd defer to whatever users want in this case: as long as we can easily explain the behavior of what we're doing, it's good!

  5. shykes commented on Dec 7, 2024

    @shykes
    Contributor

    Module config

    I'm torn on this part because it's got a foot in each world:

    • One the one hand it's directly linked to module schemas... So if it's kept in the home directory it might get out of sync with the modules it's targeting
    • At the same time, it's specifically meant to be environment-specific, so should not be checked in git along a module
    • Also, it won't target just one module. Ideally it's not just for injecting arguments into top-level function calls in a single module, but into any call at any depth. This would allow very powerful dependency injection which I think would make a lot of problems easier. That makes it feel like something that would make sense in a global config.

    In a way this is like a more strongly typed .env file. Maybe there's a way to piggyback on the convention of .env files?

    Client & engine config

    The distinction between engine config and client config assumes that the current split between client and engine is fixed and permanent, and enshrines it. In reality it is not. See #7466 for the direction we want to go, ie: tighter coupling of cli & engine until they are no longer distinguishable.

    Engine config. These settings are tied to the lifetime of an engine, and aren't specific to a user (in the case of a shared engine). Things like garbage collection, or security configuration, etc) - when these are changed, the entire behavior of the engine can change (and probably requires restarting, or at least cancelling ongoing builds). The operator writes these - not all of these are possible to move to the client (or even desirable, since the operator may want to set these separately).

    Since cli & engine are tightly coupled, "shared engine" is really "shared (engine+cli)".

    The operator simply writes their own config for their engine+cli.

    Client config. These settings are tied to the lifetime of a single dagger call/dagger shell session. And are written by the person who is actually using dagger (regardless of whether they're a module author, or an operator).

    This abstraction is already leaking, see for example your suggestion to allow a engine.json on the client machine. The lifecycle of the client & engine are not cleanly decoupled in the way that would justify a strong separation of config files, and never will be.

    TLDR: client & engine config should be combined. Module config requires more discussion to know where it should go.

  6. jedevc commented on Dec 7, 2024

    @jedevc
    ContributorAuthor

    No disagreement on where we want the architecture to be eventually - but while we're not there, having the config fused together will be confusing - but I do think we can resolve that in docs.

    If that is what we want, one fused file, some settings requiring a manual engine restart, and some not, then should we rename the existing engine.json to something else before we release, to avoid needing to rename it later on?

  7. benkeil commented on Jan 21, 2025

    @benkeil

    I would love to just use the Client.connect function to specify engine specific stuff.

    Dagger.connect(
        workingDir = "../", 
        caCertificatePath = File("/path/to/my/ca-certificates"),
    ).use { client ->
      ...
    }

    or maybe even better

    val caCertificates: List<File> = functionThatLoadsCertificates()
    
    Dagger.connect(
        workingDir = "../", 
        caCertificates = caCertificates),
    ).use { client ->
      ...
    }

    So I can get my certificates from somewhere (or what ever properties the dagger engine may need) and configure the engine. If the configuration does not match, connect creates a new engine with the configured settings.

  8. locked and limited conversation to collaborators on Mar 24, 2026
  9. converted this issue into a discussion #12136 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions