2021-06-09 16:27:24 +02:00
---
2021-07-16 18:37:29 +02:00
slug: /1003/get-started/
2021-06-09 16:27:24 +02:00
---
2021-09-24 23:43:22 +02:00
# Get Started with Dagger
2021-06-09 16:27:24 +02:00
2021-09-24 23:43:22 +02:00
In this tutorial, you will learn the basics of Dagger by building a Dagger project from scratch. This simple
project deploys a [React ](https://reactjs.org/ ) application to your local machine via docker. In later tutorials,
you will learn how to configure Dagger to deploy to your infrastructure. And, for advanced users,
2021-06-28 19:38:29 +02:00
how to share access to your infrastructure in the same way that we share access to ours now.
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
This tutorial does involve writing CUE, so if you haven’ t already, be sure to read [What is CUE? ](../introduction/1005-what_is_cue.md )
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
In this tutorial we will learn:
2021-06-16 18:50:38 +02:00
2021-09-24 23:43:22 +02:00
- How to initialize and structure a Dagger project
- About Dagger concepts such as
- the plan
- environments
- inputs and outputs
- How to write CUE for Dagger
- How to deploy an application using `dagger up`
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
## Deploy an Application Locally
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
The following instructions assume you are working locally, but could just as easily be run on a remote
machine into which you have a shell.
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
### Install Dagger
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
First, make sure [you have installed Dagger ](../1001-install.md ). You can run `dagger version` to ensure
you have the latest installed and working. For the sake of brevity and simplicity we will create directories under
your home directory, but feel free to replace `~/` with a path that works best for you.
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
### Create a Dagger Project
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
First we need a directory that will contain our `.cue` files and a `.dagger` directory which stores metadata about environments. First, create a new directory for our todoapp, then initialize the project:
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
```bash
mkdir ~/todoapp
cd ~/todoapp
dagger init
2021-06-10 15:52:10 +02:00
```
2021-09-24 23:43:22 +02:00
If you now run `ls -la` you will see 2 new directories:
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
- The `.dagger` directory will store metadata about _environments_ , _inputs_ , and _outputs_ which we will cover shortly.
- The `cue.mod` directory stores libraries such as [dagger/universe ](https://github.com/dagger/universe ) which can be _imported_ into your Dagger _plan_ .
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
Dagger will load all `.cue` files recursively in the current Dagger project. More directories can be added to help organize code.
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
> Note that Dagger, like the CUE CLI command, will only load CUE files from the `cue.mod` directory in response to `import` statements.
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
### Write a Dagger Plan
2021-06-10 15:52:10 +02:00
2021-09-24 23:43:22 +02:00
A Dagger _plan_ is written in CUE and declaratively expresses the _resources_ , _dependencies_ , and _logic_ to deploy an application to an environment.