jedevc
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Project Zenith ## Overview *Project Zenith* is the codename of a future release of Dagger, currently in development (and hopefully released soon!) The goal of the project is to make Dagger more accessible, by delivering it as a CLI tool rather than just a library. Features of Project Zenith include: * Major expansion of the `dagger` CLI, removing the need to create a custom CLI for each project. * Major expansion of the Dagger API, with a complete cross-language extension and composition system. * An open ecosystem of reusable content, to take advantage of the extension and composition system called the [Daggerverse](https://daggerverse.fly.dev/). ## How to get involved The Dagger Engine is developed in the open, and Project Zenith is no exception. * Discussions take place [on the Dagger Discord](https://discord.gg/dagger-io) in the `#project-zenith` channel. We love to hear from you, and there are no stupid questions! * Contributors and testers meet every Friday at 09:00 Pacific time [on our Discord audio room](https://discord.com/channels/707636530424053791/911305510882513037). If you get stuck, check out the [Troubleshooting guide](#troubleshooting) below. ## How to use it Pre-requisites: - A shell (bash, zsh, etc) - [Docker](https://docs.docker.com/engine/install/) ### Downloading an experimental build You can download an experimental build of dagger from [github.com/jpadams/shykes-dagger-zenith-builder](https://github.com/jpadams/shykes-dagger-zenith-builder/releases/tag/nightly). Select the right build using your OS (darwin or linux) and platform (amd64 or arm64), and move it to a directory within your path, for example: ```sh # create a personal bin directory and add it to the PATH mkdir -p ~/bin export PATH=$PATH:~/bin # install the downloaded binary mv ~/Downloads/dagger-zenith-linux-amd64 ~/bin/dagger ``` You should then be able to use the `dagger` command: ```sh dagger version # dagger devel () (jeremyatdockerhub/dagger-engine-worker-zenith) linux/amd64 ``` You can also run a quick hello world to check everything's working: ```sh dagger query <<EOF { container { from(address:"alpine") { withExec(args:["echo", "hello daggernauts!"]) { stdout } } } } EOF ``` ### Building from scratch (advanced) <details> <summary>Building from scratch instructions</summary> To get started, clone or pull this branch: ```sh # fresh clone git clone https://github.com/shykes/dagger --branch zenith-functions ./dagger/ # OR pull branch git remote add shykes https://github.com/shykes/dagger git fetch shykes zenith-functions git checkout zenith-functions ``` Next, build the dev `dagger` CLI and start the dev engine: ```sh # cd into repo cd ./dagger/ # build dev CLI and engine ./hack/dev ``` Finally, you need to configure the dagger environment variables to point to the running engine. 1. If you use [direnv](https://direnv.net/), you can just: ```sh cd ./zenith direnv allow . ``` 2. If not, you can directly `source` the provided `.envrc` file: ```sh cd ./zenith source .envrc ``` At this point you should have a fully functioning `dagger` CLI and dev engine. You should then be able to use the `dagger` command: ```sh ./bin/dagger version # dagger devel () (registry.dagger.io/engine) linux/amd64 ``` You can also run a quick hello world to check everything's working: ```sh ./bin/dagger query <<EOF { container { from(address:"alpine") { withExec(args:["echo", "hello daggernauts!"]) { stdout } } } } EOF ``` </details> ## Creating your first Module Create a new directory on your filesystem and run `dagger mod init` to bootstrap your first module. We'll call it `potato` here, but you can choose your favorite food. ```sh mkdir potato/ cd potato/ # initialize Dagger module # NOTE: currently Go is the only supported SDK. dagger mod init --name=potato --sdk=go ``` This will generate a `dagger.json` module file, an initial `main.go` source file, as well as a generated `dagger.gen.go` and `internal` folder for the generated module code. If you like, you can run the generated `main.go` like so: ```sh echo '{potato{myFunction(stringArg:"Hello daggernauts!"){id}}}' | dagger query ``` > **Note** > > All names (functions, arguments, struct fields), etc, are converted into a langauge-agnostic camel-case style. Let's try changing the `main.go`. We named our module `potato`, so that means all methods on the `Potato` type are published as functions. Let's replace the template with something simpler: ```go package main type Potato struct{} func (m *Potato) HelloWorld() string { return "Hello daggernauts!" } ``` Next, run `dagger mod sync`. **You will need to run this command after every change to your module's interface.** > **Note** > Module functions are flexible in what parameters they can take. You can include an optional `context.Context`, and an optional `error` result. These are all valid variations of the above: > ```go > func (m *Potato) HelloWorld() string > func (m *Potato) HelloWorld() (string, error) > func (m *Potato) HelloWorld(ctx context.Context) string > func (m *Potato) HelloWorld(ctx context.Context) (string, error) > ``` To run the new function, once again use `dagger query`: ```sh echo '{potato{helloWorld}}' | dagger query ``` Your functions can accept and return multiple different types, not just basic builtin types. For example, to take an object (which you can use to provide optional parameters, or to group large numbers of parameters together): ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int Mashed bool } func (m *Potato) HelloWorld(opts PotatoOptions) string { if opts.Mashed { return fmt.Sprintf("Hello world, I have mashed %d potatoes", opts.Count) } return fmt.Sprintf("Hello world, I have %d potatoes", opts.Count) } ``` These options can then be set using `dagger query` (exactly as if they'd been specified as top-level options): ```sh echo '{potato{helloWorld(count:10, mashed:true)}}' | dagger query ``` Or, to return a custom type: ```go package main type Potato struct{} // HACK: to be queried, custom object fields require `json` tags type PotatoMessage struct { Message string `json:"message"` From string `json:"from"` } // HACK: this is temporarily required to ensure that the codegen discovers // PotatoMessage func (msg PotatoMessage) Void() {} func (m *Potato) HelloWorld(message string) PotatoMessage { return PotatoMessage{ Message: message, From: "potato@example.com", } } ``` ```sh echo '{potato{helloWorld(message: "I'm a potato!"){message, from}}}' | dagger query ``` > **TODO(jedevc)** > > Do structs nest? > **TODO(jedevc)** > > Pointer options don't work ## More things you can do ### Call other modules Modules can call each other! > **TODO** > > Find a module to use as an example here To add a dependency to your module, you can use `dagger mod use`: ```sh dagger mod use github.com/.../.../... ``` This module will be added to your `dagger.json`: ```json "dependencies": [ "github.com/.../.../...@22596363b3de40b06f981fb85d82312e8c0ed511" ] ``` You can also use local modules as dependencies. However, they must be stored in a sub-directory of your module. For example: ```sh dagger mod use some_other_module ``` The module can be called using `dagger query`: ```sh echo '{...}' | dagger query ``` It'll also be added to your codegeneration, so you can access it from your own module's code: ```go func (m *Potato) HelloWorld(ctx context.Context) (string, error) { // ... } ``` You can find other modules to use on <https://daggerverse.fly.dev>. > **TODO(jedevc)** > > Are multiple module dependencies supported? #### Module locations You can consume modules from lots of different sources. The easiest way to `dagger use` or `dagger query` module is to reference it by it's GitHub URL (similar to go package strings). For example: ```sh dagger query -m "github.com/user/repo@main" <<EOF query test { ... } EOF ``` or, if your module is in a subdirectory of the Git repository: ```sh dagger query -m "github.com/user/repo/subdirectory@main" <<EOF query test { ... } EOF ``` You can also use modules from the local disk, without needing to push them to GitHub! ```sh dagger query -m "./path/to/module" <<EOF query test { ... } EOF ``` #### Publishing your own modules You can publish your own modules to <https://daggerverse.fly.dev>, so that other users can easily discover them. At the moment, daggerverse is only used to discover other modules, all the data is stored and fetched from GitHub. To publish a module, create a git repository for it and push to GitHub: ```sh # assuming your module is in "potato/" git init git add potato/ git commit -m "Initial commit" git remote add origin git@github.com:<user>/daggerverse.git git push origin main ``` Next, navigate to <https://daggerverse.fly.dev>, and use the top-module bar to paste the GitHub link to your module (`github.com/<user>/daggerverse.git`), then click "Crawl". > **Note** > > You don't *have* to use `daggerverse` as the name of your git repo -- it's just a handy way to have all your modules in one git repository together. But you can always split them out into separate repositories, or name it something different if you like! > **TODO(jedevc)** > > Are multiple module dependencies supported? ### Chaining As mentioned above, your functions can return custom objects, which in turn can define new functions! This allows for "chaining" of functions in the same style as the core Dagger API. As long as your object can be JSON-serialized by your SDK, its state will be preserved and passed to the next function in the chain. Here is an example module using the Go SDK: ```go // A dagger module for saying hello world! package main import ( "context" "fmt" ) type HelloWorld struct { Greeting string Name string } func (hello *HelloWorld) WithGreeting(ctx context.Context, greeting string) (*HelloWorld, error) { hello.Greeting = greeting return hello, nil } func (hello *HelloWorld) WithName(ctx context.Context, name string) (*HelloWorld, error) { hello.Name = name return hello, nil } func (hello *HelloWorld) Message(ctx context.Context) (string, error) { var ( greeting = hello.Greeting name = hello.Name ) if greeting == "" { greeting = "Hello" } if name == "" { name = "World" } return fmt.Sprintf("%s, %s!", greeting, name), nil } ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result will be: ```json { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` ### Extend core types You can add a new function to accept and return a `*Container`. ```go package main type Potato struct{} func (c *Container) AddPotato() *Container { return c.WithNewFile("/potato", ContainerWithNewFileOpts{ Contents: "i'm a potato", }) } ``` Next, run `dagger mod sync`. To run the new function, once again use `dagger query` (this example requires a Snyk token): ```sh dagger query <<EOF { container { from(address:"alpine") { addPotato { withExec(args:["cat", "potato"]) { stdout } } } } } EOF ``` ## Known issues - A module's public fields require a `json:"foo"` tag to be queriable. - Custom objects in a module require at least one method to be defined on them to be detected by the codegen. - When referencing another module as a local dependency, the dependent module must be stored in a sub-directory of the parent module. - Custom struct types used as parameters cannot be nested and contain other structs themselves. - Calls to functions across modules will be run exactly *once* per-session -- after that, the result will be cached, but only until the next session (a new `dagger query`, etc). - At some point, we will add more fine-grained cache-control. ## Tips and tricks - The context and error return are optional in the module's function signature; remove them if you don't need them. - A module's private fields will not be persisted. ## Troubleshooting Zenith still isn't perfectly complete! So, if you come across bugs, it helps to have some techniques for working out what's going on. If you run into problems, please share in the `#zenith-help` channel in the [Dagger Discord](https://discord.gg/dagger-io)! ### Rerun commands with `--focus=false` Sometimes, the dagger client logs are automatically collapsed and don't contain all the information from a failure. To make sure that logs aren't automatically collapsed, you can run any `dagger` subcommand with the `--focus=false` flag to disable this behavior. ### Access the `docker logs` The dagger engine runs in a dedicated container. You can find the container using `docker ps`: ``` CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ffdef3982445 jeremyatdockerhub/dagger-engine-worker-zenith:main "dagger-entrypoint.s…" 2 hours ago Up 2 hours dagger-engine-272478830461fcff ``` You can then access the logs for the container: ``` # replace <container-id> with the found id from above docker logs <container-id> ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully