Skip to main content

Get Started with the Dagger CUE SDK

Introduction

This tutorial teaches you the basics of using Dagger with CUE. You will learn how to:

  • Install the CUE SDK
  • Use the CUE SDK to build and test an application locally
  • Use the CUE SDK to build and deploy the application remotely

Requirements

This tutorial assumes that:

Step 1: Install the Dagger CUE SDK

tip

The dagger-cue CLI is available for installation on macOS, Linux, and Windows to run locally or in a CI environment.

Install the dagger-cue CLI following the steps below.

Step 2: Build, run and test locally

Everyone should be able to develop, test and run their application using a local pipeline. Having to commit and push in order to test a change slows down iteration. This step explains how to use the Dagger CUE SDK to configure a local pipeline to build, run and test an application.

Step 3: Build, run and test in a remote CI environment

Once you have the Dagger Engine running locally, it's easy to use Dagger with any CI environment (no migration required) to run the same Dagger pipelines. Any CI environment with Docker pre-installed works with Dagger out of the box.

Now that you are comfortable with the local CI/CD loop, the next step is to configure a production deployment of the application using a remote CI environment. This step will also deploy the build output to Netlify.

note

We started with CI environments that you told us you are using. If you cannot find your CI environment below, let us know via this GitHub discussion.

.github/workflows/todoapp.yml
name: todoapp

on:
push:
# Trigger this workflow only on commits pushed to the main branch
branches:
- main

# Dagger plan gets configured via client environment variables
env:
# This needs to be unique across all of netlify.app
APP_NAME: todoapp-dagger-europa
NETLIFY_TEAM: dagger

jobs:
dagger:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2

# You need to run `dagger-cue project init` locally before and commit the cue.mod directory to the repository with its contents
- name: Deploy to Netlify
uses: dagger/dagger-for-github@v3
# See all options at https://github.com/dagger/dagger-for-github
with:
version: 0.2
# To pin external dependencies, you can use `project update github.com/[package-source]@v[n]`
cmds: |
project update
do deploy
env:
# Get one from https://app.netlify.com/user/applications/personal
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}

Conclusion

This tutorial introduced you to the Dagger CUE SDK. It explained how to install the SDK and use it to build, test and deploy an application locally and remotely. It also provided code samples for common CI environments.

Use the Guides and SDK Reference to learn more about the Dagger CUE SDK.