I have a beginner question. When I look at the examples of functions, most of them use the builder pattern to declare their logic combining engine primitives such as containers, and I was wondering if functions can be imperative, for example running a system process. I have the feeling it’s possible, but it’s hard to tell from the docs.
#Logic in functions
1 messages · Page 1 of 1 (latest)
Yes, your function runs in a dedicated container, so you can use the full range of regular libraries, and regular system features, including exec. But, it will be sandboxed to that container, and you don't control what's installed inside (except via your native language package manager via the Dagger SDK)
Is that container a Docker container? Let’s say I have a Swift SDK and a function implemented in Swift:
- Is that function compiled using the host architecture? Or is it compiled inside a Docker container?
- If I want to run system commands, like xcodebuild (from Xcode), which can’t run in a Linux container, can I do so?
Yes, it's a Docker (OCI) container, using the Dagger API under the hood (the Dagger SDK which builds your Dagger module, is itself a Dagger module, it's the same Dagger API all the way down)
So the Dagger SDK uses the same API to build and run your module's runtime container, that you yourself can use to run containers in your pipeline
As a consequence of that: no, you can't execute system commands on your host system. (xcode etc). It's Linux only at the moment
Gotcha 😞
But, you can make calls to dagger functions from a script running on your local system for example
It’s more that the inverse of that is not possible? (the Dagger function calling macOS-bound tools)
Correct, that is not possible. Or only indirectly: for example you can instrument ssh commands to a remote mac server (this is something people actually do)
Do you think it’ll ever be possible to address the above without resorting to ssh connections to remote Mac servers?
Not for a while
But eventually, yes
I'm going to say, 12 months from now
(this is my educated guess as an individual, not a commitment 🙂
Actually there may be shortcuts that make that 6 months. We could make special exceptions for well-known software like xcode
I think that if we get design consensus on how to special-case well-know, trusted software on the host (eg. xcode, we could conceivably accelerate this)
Can you tell me more about your use case @lime relic ?
The iOS community is settled in a Ruby tool, Fastlane, which provides a DSL for automation plus some building blocks to ease automation.
The community would prefer to write those in Swift, so I want to build something and I thought, wait a second, Dagger could enable that, and not only that but free them from the vendor locking of proprietary pipelines.
The tools that are used the most that require macOS are those provided by Apple, which live in a conventional path that Dagger could detect.
I think if something like this was implemented, you’d gain a good chunk of the Swift community.