Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Updates quickstart examples #7172

Merged
merged 6 commits into from Apr 30, 2024

Conversation

vikram-dagger
Copy link
Contributor

@vikram-dagger vikram-dagger commented Apr 24, 2024

This is the first in a series of commits to improve the Dagger quickstart. In response to user feedback that some of the examples are too simplistic and "hello world"-y, this commit tightens up the current quickstart to remove or update those examples. Larger structural changes will follow in separate PRs.

Signed-off-by: Vikram Vaswani <[email protected]>
Copy link
Contributor

@levlaz levlaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big improvement, I love the new examples, I added a bit of feedback.

```

:::tip
All of Dagger's core types - `Directory`, `File`, `Container`, `Service`, `Secret` and others - can be used as arguments by Dagger Functions. It's important to know that these core types are not merely strings referencing local or remote resources; they are actual representations of the corresponding resource states, managed by the Dagger Engine, and passed to and between Dagger Functions like other variables. This feature, as far as we know, is unique to Dagger, and opens endless possibilities for assembling complex pipelines where container state flows from function to function - in just a few lines of code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and others

We said this in a few places, are there other core types? If so, why not list them all here?

It's important to know that

This feels excessive, its already important since we put it in this callout block.

This feature, as far as we know, is unique to Dagger, and opens endless possibilities for assembling complex pipelines where container state flows from function to function - in just a few lines of code.

This one feels a bit too "markety" for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -21,7 +20,7 @@ Try calling this Go builder function:
dagger -m github.com/kpenfound/dagger-modules/[email protected] call build --project https://github.com/dagger/dagger --args ./cmd/dagger
```

This function takes a `proj` argument of type `Directory`. Similar to how the CLI can pass a `Container` from a remote OCI address, it can also pass a `Directory` from a local path or remote Git address. Here, you're passing the address of Dagger's open-source repository.
This function takes a `project` argument of type `Directory`. Here, you're passing the address of Dagger's open-source repository.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also describe what the --args ./cmd/dagger argument does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final export example only works with linux, I think we should make a note of that somehow or update the function to accept an OS argument.

http://localhost:3000/quickstart/853930/directories#export-the-build-directory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in a previous commit using uname

```

### Publish the container image to a registry

The `Container` type also has a `Publish()` function, which publishes the container to a registry. To see this in action, call the previous function again, this time chaining an additional function call to `Publish()` on the returned `Container`:
The `Container` type also makes a number of other functions available. To see some of these in action, call the previous function again, chaining additional function calls to `WithEntrypoint()` and `Publish()` on the returned `Container` to, respectively, set the container entrypoint command and publish it to a registry:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, respectively, feels excessive, I think removing it makes it easier to read this sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

1. Initialize a new Dagger Module with `dagger init`
2. Install other useful Dagger Modules as dependencies with `dagger install`
1. Initialize a new Dagger module with `dagger init`
2. Install other useful Dagger modules as dependencies with `dagger install`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is a good place to link to the daggerverse, otherwise what would someone be installing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@@ -14,14 +14,14 @@ So far, you've been calling individual Dagger Functions using the Dagger CLI. Bu

One option is, of course, to stitch together calls using the CLI and a shell script or a Makefile However, this approach is not recommended, because you will typically end up with long and unwieldy CLI commands and shell scripting "glue" that is hard to debug and maintain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, of course,

I think this style makes sense in conversation but feels cumbersome to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


By creating your own Dagger Module and installing other modules into it, you can express more complex workflows and operations by reusing modules created by others and connecting them together using the programming language you're most comfortable with.
By creating your own Dagger Function, you can express more complex workflows and operations by reusing Dagger Functions created by others and connecting them together using the programming language you're most comfortable with.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating your own Dagger Function(s) enables you to transform your workflows into structured, discrete and composable units with clear inputs and outputs, with all the benefits of using a native programming language.

By creating your own Dagger Function, you can express more complex workflows and operations by reusing Dagger Functions created by others and connecting them together using the programming language you're most comfortable with.

It feels like this repeats the previous sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the main sample formatting to be a bit easier to read and write?

func (m *Example) BuildAndPublish(
	ctx context.Context,
	buildSrc *Directory,
	buildArgs []string,
) (string, error) {
	ctr := dag.Wolfi().Container()

	return dag.
		Golang().
		BuildContainer(
			GolangBuildContainerOpts{
				Source: buildSrc,
				Args:   buildArgs,
				Base:   ctr,
			}).
		Publish(
			ctx,
			fmt.Sprintf(
				"ttl.sh/my-hello-container-%.0f",
				math.Floor(rand.Float64()*10000000),
			),
		)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

@vikram-dagger vikram-dagger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added feedback

```

:::tip
All of Dagger's core types - `Directory`, `File`, `Container`, `Service`, `Secret` and others - can be used as arguments by Dagger Functions. It's important to know that these core types are not merely strings referencing local or remote resources; they are actual representations of the corresponding resource states, managed by the Dagger Engine, and passed to and between Dagger Functions like other variables. This feature, as far as we know, is unique to Dagger, and opens endless possibilities for assembling complex pipelines where container state flows from function to function - in just a few lines of code.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

1. Initialize a new Dagger Module with `dagger init`
2. Install other useful Dagger Modules as dependencies with `dagger install`
1. Initialize a new Dagger module with `dagger init`
2. Install other useful Dagger modules as dependencies with `dagger install`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in a previous commit using uname

@@ -21,7 +20,7 @@ Try calling this Go builder function:
dagger -m github.com/kpenfound/dagger-modules/[email protected] call build --project https://github.com/dagger/dagger --args ./cmd/dagger
```

This function takes a `proj` argument of type `Directory`. Similar to how the CLI can pass a `Container` from a remote OCI address, it can also pass a `Directory` from a local path or remote Git address. Here, you're passing the address of Dagger's open-source repository.
This function takes a `project` argument of type `Directory`. Here, you're passing the address of Dagger's open-source repository.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

```

### Publish the container image to a registry

The `Container` type also has a `Publish()` function, which publishes the container to a registry. To see this in action, call the previous function again, this time chaining an additional function call to `Publish()` on the returned `Container`:
The `Container` type also makes a number of other functions available. To see some of these in action, call the previous function again, chaining additional function calls to `WithEntrypoint()` and `Publish()` on the returned `Container` to, respectively, set the container entrypoint command and publish it to a registry:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -14,14 +14,14 @@ So far, you've been calling individual Dagger Functions using the Dagger CLI. Bu

One option is, of course, to stitch together calls using the CLI and a shell script or a Makefile However, this approach is not recommended, because you will typically end up with long and unwieldy CLI commands and shell scripting "glue" that is hard to debug and maintain.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


By creating your own Dagger Module and installing other modules into it, you can express more complex workflows and operations by reusing modules created by others and connecting them together using the programming language you're most comfortable with.
By creating your own Dagger Function, you can express more complex workflows and operations by reusing Dagger Functions created by others and connecting them together using the programming language you're most comfortable with.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Signed-off-by: Vikram Vaswani <[email protected]>
@vikram-dagger
Copy link
Contributor Author

Ping @levlaz for second review and @kpenfound for first review

@vikram-dagger vikram-dagger merged commit 82c832e into dagger:main Apr 30, 2024
31 checks passed
kpenfound pushed a commit to kpenfound/dagger that referenced this pull request May 2, 2024
* docs: Updates quickstart examples

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed capitalization according to new style guide

Signed-off-by: Vikram Vaswani <[email protected]>

* Updates examples

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Added feedback

Signed-off-by: Vikram Vaswani <[email protected]>

---------

Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: kpenfound <[email protected]>
vikram-dagger added a commit to vikram-dagger/dagger that referenced this pull request May 3, 2024
* docs: Updates quickstart examples

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed capitalization according to new style guide

Signed-off-by: Vikram Vaswani <[email protected]>

* Updates examples

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Added feedback

Signed-off-by: Vikram Vaswani <[email protected]>

---------

Signed-off-by: Vikram Vaswani <[email protected]>
vikram-dagger added a commit to vikram-dagger/dagger that referenced this pull request May 3, 2024
* docs: Updates quickstart examples

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed capitalization according to new style guide

Signed-off-by: Vikram Vaswani <[email protected]>

* Updates examples

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Added feedback

Signed-off-by: Vikram Vaswani <[email protected]>

---------

Signed-off-by: Vikram Vaswani <[email protected]>
vikram-dagger added a commit to vikram-dagger/dagger that referenced this pull request May 3, 2024
* docs: Updates quickstart examples

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed capitalization according to new style guide

Signed-off-by: Vikram Vaswani <[email protected]>

* Updates examples

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Added feedback

Signed-off-by: Vikram Vaswani <[email protected]>

---------

Signed-off-by: Vikram Vaswani <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants