Use Dagger SDKs in CI
Introduction
This guide explains how to integrate the Dagger SDKs with various CI services/tools.
Requirements
This guide assumes that:
- You have a Go, Python or Node.js environment on the CI runner.
- You have a Dagger SDK for one of the above languages installed on the CI runner. If not, install your preferred language SDK within your CI workflow following the installation instructions for the Dagger Go, Python or Node.js SDK.
Use Dagger in CI
GitHub Actions
- Go
- Node.js
- Python
.github/workflows/dagger.yml
name: dagger
on:
push:
branches: [main]
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.20'
- uses: actions/checkout@v3
- name: Run Dagger pipeline
run: go run main.go
.github/workflows/dagger.yaml
name: dagger
on:
push:
branches: [main]
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/checkout@v3
- name: Install deps
run: npm ci
- name: Run Dagger pipeline
run: node index.mjs
.github/workflows/dagger.yaml
name: dagger
on:
push:
branches: [main]
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: actions/checkout@v3
- name: Install deps
run: pip install -r requirements.txt
- name: Run Dagger pipeline
run: python main.py
GitLab CI
- Go
- Node.js
- Python
.gitlab-ci.yml
.docker:
image: golang:1.20-alpine
services:
- docker:${DOCKER_VERSION}-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_VERIFY: '1'
DOCKER_TLS_CERTDIR: '/certs'
DOCKER_CERT_PATH: '/certs/client'
DOCKER_DRIVER: overlay2
DOCKER_VERSION: '20.10.16'
.dagger:
extends: [.docker]
before_script:
- apk add docker-cli
build:
extends: [.dagger]
script:
- go run main.go
.gitlab-ci.yml
.docker:
image: node:18-alpine
services:
- docker:${DOCKER_VERSION}-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_VERIFY: '1'
DOCKER_TLS_CERTDIR: '/certs'
DOCKER_CERT_PATH: '/certs/client'
DOCKER_DRIVER: overlay2
DOCKER_VERSION: '20.10.16'
.dagger:
extends: [.docker]
before_script:
- apk add docker-cli
build:
extends: [.dagger]
script:
- npm ci
- node index.mjs
.gitlab-ci.yml
.docker:
image: python:3.11-alpine
services:
- docker:${DOCKER_VERSION}-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_VERIFY: '1'
DOCKER_TLS_CERTDIR: '/certs'
DOCKER_CERT_PATH: '/certs/client'
DOCKER_DRIVER: overlay2
DOCKER_VERSION: '20.10.16'
.dagger:
extends: [.docker]
before_script:
- apk add docker-cli
build:
extends: [.dagger]
script:
- pip install -r requirements.txt
- python main.py
CircleCI
- Go
- Node.js
- Python
.circleci/config.yml
version: 2.1
jobs:
build:
docker:
- image: cimg/go:1.20
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Dagger Pipeline
command: go run main.go
workflows:
dagger:
jobs:
- build
.circleci/config.yml
version: 2.1
jobs:
build:
docker:
- image: cimg/node:lts
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Install deps
command: npm ci
- run:
name: Dagger Pipeline
command: node index.mjs
workflows:
dagger:
jobs:
- build
.circleci/config.yml
version: 2.1
jobs:
build:
docker:
- image: cimg/python:3.11
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Install deps
command: pip install -r requirements.txt
- run:
name: Dagger Pipeline
command: python main.py
workflows:
dagger:
jobs:
- build
Jenkins
- Go
- Node.js
- Python
Jenkinsfile
pipeline {
agent { label 'dagger' }
stages {
stage("dagger") {
steps {
sh '''
go run main.go
'''
}
}
}
}
Requires docker
client and go
installed on your Jenkins agent, a Docker host available (can be docker:dind
), and agents labeled in Jenkins with dagger
.
Jenkinsfile
pipeline {
agent { label 'dagger' }
stages {
stage("dagger") {
steps {
sh '''
npm ci
node index.mjs
'''
}
}
}
}
Requires docker
client and node
installed on your Jenkins agent, a Docker host available (can be docker:dind
), and agents labeled in Jenkins with dagger
.
Jenkinsfile
pipeline {
agent { label 'dagger' }
stages {
stage("dagger") {
steps {
sh '''
pip install -r requirements.txt
python main.py
'''
}
}
}
}
Requires docker
client and python
installed on your Jenkins agent, a Docker host available (can be docker:dind
), and agents labeled in Jenkins with dagger
.