Add the must-have pages for the Europa release
The goal is to capture the shape of the new docs. It is not meant to be
final, but it should be as close as possible. We only want the bare
minimum for new users that on-board with Dagger Europa. As soon as the
new europaSidebar replaces replaces the existing one, the previous docs
will still remain available - doc IDs are unique and permanent. We will
do this by simply changing the default `slug: /` to point to the Europa
Docs entrypoint, which is doc 1200.
Helpful Docusaurus link re multiple sidebars:
https://docusaurus.io/docs/sidebar/multiple-sidebars
The new pages are numbered from `1200` onwards. This is meant to reflect
the `0.2.0` Dagger version. This numbering felt more meaningful than
just continuing to increment existing numbers.
I didn't want to be "wasteful" with the digits and start at `2000`, but
that was my first instinct.
I am keen on getting this live on https://docs.dagger.io/1200/local-ci.
Anything that is not in production, is inventory. Inventory is bad.
The goal is to allow anyone that has a link to get a feel for the new
docs as soon as possible, so that we can all see how they improve in
real-time, and steer them continuously towards the desired state. We
should be aware of the timeline, and not muck about, but instead
evaluate constantly how close are we to "flipping the switch".
Remember, the best releases are those where switches are flipped (e.g.
`--europa)`. The feature will have been out there for weeks (maybe even
months), improved by talking to users and then one day realising that we
are done, and just enabling it by default. It's the same principle
behind these docs.
Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2022-02-07 23:16:01 +01:00
---
slug: /1202/plan
2022-03-03 16:05:07 +01:00
displayed_sidebar: europa
Add the must-have pages for the Europa release
The goal is to capture the shape of the new docs. It is not meant to be
final, but it should be as close as possible. We only want the bare
minimum for new users that on-board with Dagger Europa. As soon as the
new europaSidebar replaces replaces the existing one, the previous docs
will still remain available - doc IDs are unique and permanent. We will
do this by simply changing the default `slug: /` to point to the Europa
Docs entrypoint, which is doc 1200.
Helpful Docusaurus link re multiple sidebars:
https://docusaurus.io/docs/sidebar/multiple-sidebars
The new pages are numbered from `1200` onwards. This is meant to reflect
the `0.2.0` Dagger version. This numbering felt more meaningful than
just continuing to increment existing numbers.
I didn't want to be "wasteful" with the digits and start at `2000`, but
that was my first instinct.
I am keen on getting this live on https://docs.dagger.io/1200/local-ci.
Anything that is not in production, is inventory. Inventory is bad.
The goal is to allow anyone that has a link to get a feel for the new
docs as soon as possible, so that we can all see how they improve in
real-time, and steer them continuously towards the desired state. We
should be aware of the timeline, and not muck about, but instead
evaluate constantly how close are we to "flipping the switch".
Remember, the best releases are those where switches are flipped (e.g.
`--europa)`. The feature will have been out there for weeks (maybe even
months), improved by talking to users and then one day realising that we
are done, and just enabling it by default. It's the same principle
behind these docs.
Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2022-02-07 23:16:01 +01:00
---
# It all starts with a plan
2022-03-03 23:06:33 +01:00
2022-03-25 15:25:01 +01:00
## Plan structure
2022-03-03 23:06:33 +01:00
2022-03-25 15:25:01 +01:00
A config declared in Dagger starts with a plan, specifically `dagger.#Plan`
2022-03-09 19:10:52 +01:00
2022-03-25 15:25:01 +01:00
Within this plan we can:
2022-03-03 23:06:33 +01:00
2022-03-25 15:25:01 +01:00
- interact with the `client` filesystem
- read files, usually the current directory as `.`
- write files, usually the build output as `_build`
- read `env` variables, such as `NETLIFY_TEAM` in our example
- declare a few `actions` , e.g. `deps` , `test` & `build`
This is our **Getting Started** todoapp plan structure:
2022-03-03 23:06:33 +01:00
2022-03-10 17:27:52 +01:00
```cue file=../tests/core-concepts/plan/structure.cue.fragment
2022-03-03 23:06:33 +01:00
```
2022-03-09 19:10:52 +01:00
When the above plan gets executed via `dagger do build` , it produces the following output:
2022-03-03 23:06:33 +01:00
```shell
2022-03-25 15:25:01 +01:00
[✔] client.filesystem.".".read 0.0s
[✔] actions.deps 1.1s
[✔] actions.test.script 0.0s
[✔] actions.test 0.0s
[✔] actions.build.run.script 0.0s
[✔] actions.build.run 0.0s
[✔] actions.build.contents 0.0s
[✔] client.filesystem."./_build".write 0.1s
2022-03-03 23:06:33 +01:00
```
2022-03-25 15:25:01 +01:00
Since these actions have run before, they are cached and take less than 2 seconds to complete.
2022-03-03 23:06:33 +01:00
2022-03-25 15:25:01 +01:00
While the names used for the actions above - `deps` , `test` & `build` - are short and descriptive,
2022-03-03 23:06:33 +01:00
any other names would have worked. Put differently, action naming does not affect plan execution.
2022-03-25 15:25:01 +01:00
Lastly, notice that even if the `deploy` action is defined, we did not run it.
Similar to Makefile targets, we have the option of running specific actions.
We ran the `dagger do build` command, which only runs the `build` action (and all its dependent actions).
This Dagger property enables us to keep the entire CI/CD config in a single file, while keeping the integration execution separate from the deployment one.
Separating CI & CD concerns becomes essential as our pipelines grow in complexity, and we learn about operational and security constraints specific to our systems.
2022-03-03 23:06:33 +01:00
2022-03-25 15:25:01 +01:00
## Packages & imports
2022-03-09 19:10:52 +01:00
2022-03-25 15:25:01 +01:00
In order to understand the correlation between actions, definitions and packages, let us focus on the following fragment from our **Getting Started** todoapp config:
2022-03-03 23:06:33 +01:00
```cue
2022-03-25 15:25:01 +01:00
package todoapp
import (
"dagger.io/dagger"
"universe.dagger.io/netlify"
)
dagger.#Plan & {
// ...
actions: {
// ...
deploy: netlify.#Deploy & {
2022-03-03 23:06:33 +01:00
// ...
}
2022-03-25 15:25:01 +01:00
// ...
}
}
2022-03-03 23:06:33 +01:00
```
2022-03-25 15:25:01 +01:00
We start by declaring the package name, `package todoapp` above.
2022-03-03 23:06:33 +01:00
2022-03-25 15:25:01 +01:00
Next, we import the packages that we use in our plan.
2022-03-03 23:06:33 +01:00
2022-03-25 15:25:01 +01:00
The first import is needed for the `dagger.#Plan` definition to be available.
The second import is for `netlify.#Deploy` to work.
:::info
Which other imports we are missing?
Look at all the actions in the plan structure at the top of this page.
2022-03-29 20:41:59 +02:00
Now check all the available packages in [universe.dagger.io ](https://github.com/dagger/dagger/tree/v0.2.4/pkg/universe.dagger.io ).
2022-03-25 15:25:01 +01:00
:::
We now understand that the `deploy` action is the deploy definition from the netlify package, written as `deploy: netlify.#Deploy`
Each definition has default values that can be modified via curly brackets. This is what that looks like in practice for our deploy action:
2022-03-03 23:06:33 +01:00
```cue
2022-03-25 15:25:01 +01:00
// ...
deploy: netlify.#Deploy & {
contents: build.contents.output
site: client.env.APP_NAME
token: client.env.NETLIFY_TOKEN
team: client.env.NETLIFY_TEAM
}
// ...
2022-03-03 23:06:33 +01:00
```
2022-03-25 15:25:01 +01:00
We can build complex pipelines efficiently by referencing any definition, from any package in our actions.
This is one of the fundamental concepts that makes Dagger a powerful language for building CI/CD pipelines.
If you want to learn more packages in the context of CUE, the config language used by Dagger configs, check out the [Packages ](1215-what-is-cue.md#packages ) section on the **What is CUE?** page.
2022-03-09 19:10:52 +01:00
:::tip
Now that we understand the basics of a Dagger plan, we are ready to learn more about how to interact with the client environment.
2022-03-25 15:25:01 +01:00
We can read the env (including secrets), run commands, use local sockets, etc.
2022-03-09 19:10:52 +01:00
:::