docs: specify env when using dagger + fix docs_101 ambiguous naming and english mistakes + change method, now cue.mod

Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
Guillaume de Rouville
2021-06-28 19:38:29 +02:00
parent 0ba7c1fb44
commit 9171912918
3 changed files with 100 additions and 98 deletions

View File

@@ -116,7 +116,7 @@ But you can call your packages anything you want.
Let's create a new directory for our Cue package:
```shell
mkdir multibucket
mkdir cue.mod/multibucket
```
### Component 1: app source code
@@ -130,7 +130,7 @@ In Dagger terms, this component has two essential properties:
Let's write the corresponding Cue code to a new file in our package:
```cue title="todoapp/multibucket/source.cue"
```cue title="todoapp/cue.mod/multibucket/source.cue"
package multibucket
import (
@@ -147,7 +147,7 @@ This code defines a component at the key `src`, and specifies that it is both an
The second component of our plan is the Yarn package built from the app source code:
```cue title="todoapp/multibucket/yarn.cue"
```cue title="todoapp/cue.mod/multibucket/yarn.cue"
package multibucket
import (
@@ -176,7 +176,7 @@ _FIXME_: this section is not yet available because the [Amazon S3 package](https
The third component of our plan is the Netlify site to which the app will be deployed:
```cue title="todoapp/multibucket/netlify.cue"
```cue title="todoapp/cue.mod/multibucket/netlify.cue"
package multibucket
import (
@@ -216,27 +216,56 @@ You can also browse the [Dagger Universe](../reference/universe/README.md) refer
Now that your Cue package is ready, let's create an environment to run it:
```shell
dagger new 'multibucket'
dagger new 'multibucket' -m cue.mod/multibucket
```
### Load the plan into the environment
Now let's configure the new environment to use our package as its plan:
```shell
cp multibucket/*.cue .dagger/env/multibucket/plan/
```
Note: you need to copy the files from your package into the environment, as shown above.
If you make more changes to your package, you will need to copy the new version, or it will not be used.
In the future, we will add the ability to reference your Cue package directory, making this manual copy unnecessary.
### Configure user inputs
[This section is not yet written](https://github.com/dagger/dagger/blob/main/CONTRIBUTING.md)
You can inspect the list of inputs (both required and optional) using dagger input list:
```shell
dagger input list -e multibucket
# Input Value Set by user Description
# site.netlify.account.name *"" | string false Use this Netlify account name (also referred to as "team" in the Netlify docs)
# site.netlify.account.token dagger.#Secret false Netlify authentication token
# site.netlify.name string false Deploy to this Netlify site
# site.netlify.create *true | bool false Create the Netlify site if it doesn't exist?
# src dagger.#Artifact false Source code of the sample application
# app.cwd *"." | string false working directory to use
# app.writeEnvFile *"" | string false Write the contents of `environment` to this file, in the "envfile" format
# app.buildDir *"build" | string false Read build output from this directory (path must be relative to working directory)
# app.script *"build" | string false Run this yarn script
# app.args *[] | [] false Optional arguments for the script
```
All the values without default values (without `*`) have to be specified by the user. Here, required fields are:
- `site.netlify.account.token`, your access token
- `site.netlify.name`, name of the published website
- `src`, source code of the app
Please note the type of the user inputs: a string, a #Secret and an artifact. Let's see how to input them:
```shell
# As a string input is expected for `site.netlify.name`, we set a `text` input
dagger input text site.netlify.name <GLOBALLY-UNIQUE-NAME> -e multibucket
# As a secret input is expected for `site.netlify.account.token`, we set a `secret` input
dagger input secret site.netlify.account.token <PERSONAL-ACCESS-TOKEN> -e multibucket
# As an Artifact is exepected for `src`, we set a `dir` input (dagger input list for alternatives)
dagger input dir src . -e multibucket
```
### Deploy
Now that everything is properly set, let's deploy on Netlify:
```shell
dagger up -e multibucket
```
[This section is not yet written](https://github.com/dagger/dagger/blob/main/CONTRIBUTING.md)
### Using the environment