#Hey folks,
1 messages ยท Page 1 of 1 (latest)
Hi ๐
This is a good place to start: https://docs.dagger.io/quickstart/ci?sdk=typescript
It walks through a basic CI pipeline in typescript
And yes, you can install any module from daggerverse! This one for example provides utilities for working with nodejs projects which will save you from writing a lot of the same code https://daggerverse.dev/mod/github.com/Dudesons/daggerverse/node@3ccb51d1ce00e058e5fb9715b05dd9b57f1f63db
For caching, we currently don't have the equivalent of actions/setup-node. We've had a previous solution tied to dagger cloud and we're working on what the next version of distributed caching for Dagger looks like. In the meantime, good options are Depot runners (https://docs.dagger.io/ci/integrations/github-actions/#about-depot) or self hosted runners on Kubernetes https://docs.dagger.io/ci/integrations/kubernetes/
thanks a lot @bleak wasp
And yes, you can install any module from daggerverse! This one for example provides utilities for working with nodejs projects which will save you from writing a lot of the same code https://daggerverse.dev/mod/github.com/Dudesons/daggerverse/node@3ccb51d1ce00e058e5fb9715b05dd9b57f1f63db
I've two more noob question.
1- Is there any example how should I import any this to my own module?
2- Seems most of the modules in daggerverse written with go.. Is it somehow possible to import go module to typescript module?
Good questions! Once you run dagger install github.com/Dudesons/daggerverse/node@v0.5.0 you'll see that module get added to your dependencies in your dagger.json which extends the Dagger API with this module added to it. Basically, you'll be able to access all of those functions with dag.node(), like dag.node().withNpm() for example. All dependencies are added to the generated client when they're installed (or when you run dagger develop) so you should see type hints and everything in your IDE
The cool thing is that since modules are accessed through the Dagger API, a dependency can be written in any language and it will still be usable in your language through the Dagger client (dag)
For example, this project has a dependency on a module called github-issue, which happens to be written in Go https://github.com/kpenfound/hello-dagger-ts/blob/main/dagger.json#L10
and here's the typescript code using that dependency https://github.com/kpenfound/hello-dagger-ts/blob/main/.dagger/src/index.ts#L106
@bleak wasp super helpful! really appreciated..
I'm still learning as well, so bear with me and ask for clarification as needed.
Here's what I wish I had known when I started down this path:
- Dagger shell is very powerful, and you can do almost anything that your module will do in the shell for rapid prototyping. Seriously, before you start building something just try it in the shell. I prototyped my Daml module from the previous thread without my module:
sha256:3e2b891f7e313b8e367befe713065acce11bda4d40b03a07f595ba5addaaac93
โ project | build | file | digest 0.0s
sha256:3e2b891f7e313b8e367befe713065acce11bda4d40b03a07f595ba5addaaac93
-
You can compose modules using the shell, just by pointing at a source directory or a Github repository. (e.g.
github.com/sagikazarmark/daggerverse/helm@v0.14.0 | .helpand you're off and running with the Helm module -
Check out the Helm module as (what seemed to me) as a great example of module design. It's written in Go, but it translates well to TypeScript) https://github.com/sagikazarmark/daggerverse/tree/4981f49ead356d64a860ef85caec9b0622933ad7/helm
Re: dagger shell + prototyping, it took me a little bit to learn shell syntax for arguments like Directory, File, arrays, etc. After that clicked for me, everything else just started to fall into place. I could visualize the no-module version DAG, and then I would thin about how I wanted to represent it in a noun | verb | ... | noun syntax to make it easier for my use case.
I also started to make significant strides once I started treating dagger shell like a proper shell (and a type-safe one at that). You can subshell ($(other | dagger | pipelines)) or variables (excludes=*,!**/*.daml,!.daml/,!**/daml.yaml,!**/*.dar and use --excludes $excludes in my example), and other interesting things.
thanks @near carbon ...
is it possible to exec the filesystem of the container created by dagger with shell ?
Yeah, just add | terminal to a Container and you're good to go. You can even drop that in a module and debug your module that way.
For instance when I ran this dagger call container-echo --string-arg="Test", it's a ephmeral container, how should i run this with dagger shell to understand what's going on really
import { dag, Container, Directory, object, func } from "@dagger.io/dagger"
@object()
export class Node {
/**
* Returns a container that echoes whatever string argument is provided
*/
@func()
containerEcho(stringArg: string): Container {
return dag.container().from("alpine:latest").withExec(["echo", stringArg])
}
/**
* Returns lines that match a pattern in the files of the provided Directory
*/
@func()
async grepDir(directoryArg: Directory, pattern: string): Promise<string> {
return dag
.container()
.from("alpine:latest")
.withMountedDirectory("/mnt", directoryArg)
.withWorkdir("/mnt")
.withExec(["grep", "-R", pattern, "."])
.stdout()
}
}
Between .from and withExec add a .terminal() then run.
Or you can also just run dagger shell and get the actual shell, and from there you could run container-echo Test
The ah-hah moment for me was when I was able to do the same things via dagger call, dagger shell, and my own module. I think it's important to understand that it's all the same GraphQL DAG under the covers. At that point it's a lot easier to debug and troubleshoot because it's more obvious if the problem is in my module code, the usage of it, the call/shell command etc.
ok - but can I exec and run ls -la to see the file structure inside container ? ๐
@func()
containerEcho(stringArg: string): Container {
return dag.container().from("alpine:latest").terminal().withExec(["echo", stringArg])
}
You can if you edit your module to do that... and reload dagger shell ๐
Gotcha!