Skip to content

Commit

Permalink
Improve guides/programming.md
Browse files Browse the repository at this point in the history
Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com>
  • Loading branch information
tjovicic committed Jun 7, 2021
1 parent a002d2e commit 862cf55
Showing 1 changed file with 51 additions and 29 deletions.
80 changes: 51 additions & 29 deletions docs/guides/programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,45 @@ slug: /programming

# Dagger Programming Guide

## Overview
## Writing your first Dagger plan

1. A developer writes a _plan_ specifying how to deliver their application. Plans are written in the [Cue](https://cuelang.org) data language.
2. Dagger executes plans in isolated _environments_. Each environment has its own configuration and state.

## Programming in Cue

[Cue](https://cuelang.org) is a next-generation data language by Marcel van Lohuizen and the spiritual successor
of GCL, the language used to configure all of Google's infrastructure.

Cue extends JSON with powerful features:

- Composition: layering, templating, references
- Correctness: types, schemas
- Developer experience: comments, packages, first-class tooling, builtin functions
- And mucn more.
1\. Initialize a Dagger workspace anywhere in your git repository:

To get started with Cue, we recommend the following resources:
`dagger init`

- [Cuetorials](https://cuetorials.com)
- [Cue playground](https://cuelang.org/play)
It will create a `.dagger` directory in your current directory with an empty `env` directory inside it:

## Writing your first plan
```bash
.dagger/
└── env
```

To create a Dagger plan:
2\. Create a new environment, for example `staging`:

1\. Initialize a Dagger workspace anywhere in your git repository.
`dagger new staging`

`dagger init`.
```bash
.dagger/
└── env
└── staging
├── plan
└── values.yaml

2\. Create a new environment.
```

For example: `dagger new staging`.
3\. Create a new file [Cue](#programming-in-cue) config file in `.dagger/env/staging/plan`, and open it with any text editor or IDE:

3\. Create a new file with the _.cue_ extension in `.dagger/env/staging/plan`, and open it with any text editor or IDE.
```bash
.dagger/
└── env
└── staging
├── plan
│   └── staging.cue
└── values.yaml

For example: `.dagger/env/staging/plan/staging.cue`.
```

4\. Describe each relay in your plan as a field in the cue configuration.
4\. Describe each [relay](#relays) in your plan as a field in the Cue configuration:

For example:

Expand Down Expand Up @@ -78,7 +78,7 @@ For more inspiration, see these examples:

5\. Extend your plan with relay definitions from [Dagger
Universe](https://github.com/dagger/dagger/tree/main/stdlib), an encyclopedia of
cue packages curated by the Dagger community.
Cue packages curated by the Dagger community.

6\. If you can't find the relay you need in the Universe, you can simply create your own.

Expand Down Expand Up @@ -111,8 +111,30 @@ american: #Greeting & {
}
```

## Programming in Cue

[Cue](https://cuelang.org) is a next-generation data language by Marcel van Lohuizen and the spiritual successor
of GCL, the language used to configure all of Google's infrastructure.

Cue extends JSON with powerful features:

- Composition: layering, templating, references
- Correctness: types, schemas
- Developer experience: comments, packages, first-class tooling, builtin functions
- And much more.

To get started with Cue, we recommend the following resources:

- [Cuetorials](https://cuetorials.com)
- [Cue playground](https://cuelang.org/play)

## Concepts

### Overview

1. A developer writes a _plan_ specifying how to deliver their application. Plans are written in the [Cue](https://cuelang.org) data language.
2. Dagger executes plans in isolated _environments_. Each environment has its own configuration and state.

### Plans

A _plan_ specifies, in code, how to deliver a particular application in a particular way.
Expand Down Expand Up @@ -201,7 +223,7 @@ A relay is typically contained in a [cue definition](https://cuetorials.com/over
For example a relay for a git repository might be defined as `#Repository`.

The processing pipeline is a crucial feature of Dagger. It uses the [LLB](https://github.com/moby/buildkit)
executable format pioneered by the Buildkit project. It allows Dagger components to run
executable format pioneered by the BuildKit project. It allows Dagger components to run
sophisticated pipelines to ingest produce artifacts such as source code, binaries, database exports, etc.
Best of all, LLB pipelines can securely build and run any docker container, effectively making Dagger
scriptable in any language.
Expand Down

0 comments on commit 862cf55

Please sign in to comment.