Skip to content

Commit c3f2195

Browse files
committed
Europa docs: From local dev to CI environment doc page
The todoapp example contains a Netlify plan which uses the latest dagger additions: do & Client API. We are thinking of merging the examples repository into this one to make working with this easier. This is a step in that direction. We are not using the yarn package so that we can revert #1673 without breaking this implementation. The GitHub Action is WIP, we will continue with that tomorrow: dagger/dagger-for-github#24 Signed-off-by: Gerhard Lazu <[email protected]>
1 parent 2a6962d commit c3f2195

File tree

24 files changed

+11701
-97
lines changed

24 files changed

+11701
-97
lines changed

.github/workflows/todoapp.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: todoapp
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '.github/workflows/todoapp.yml'
9+
- 'pkg/universe.dagger.io/examples/todoapp/**'
10+
11+
env:
12+
# This needs to be unique across all of Netlify
13+
APP_NAME: todoapp-dagger-europa
14+
NETLIFY_TEAM: blocklayer
15+
# https://app.netlify.com/user/applications/personal
16+
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
17+
DAGGER_LOG_FORMAT: plain
18+
19+
jobs:
20+
dagger:
21+
name: "Deploy todoapp to Netlify"
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: "Clone repository"
25+
uses: actions/checkout@v2
26+
with:
27+
fetch-depth: 0
28+
29+
# TODO: maybe use Dagger action post 0.2.0-beta.1
30+
- name: "Setup Go"
31+
uses: actions/setup-go@v1
32+
with:
33+
go-version: 1.16
34+
35+
- name: "Install dev Dagger"
36+
run: |
37+
make dagger
38+
39+
- name: "Dagger"
40+
run: |
41+
cd pkg/universe.dagger.io/examples/todoapp
42+
${{ github.workspace }}/cmd/dagger/dagger do deploy

docs/getting-started/1201-ci-environment.md

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ displayed_sidebar: europa
55

66
# From local dev to CI environment
77

8+
Dagger can be used with any CI environment (no migration required) and has two important advantages which make the overall experience less error-prone and more efficient:
9+
10+
1. Instead of YAML you write CUE: typed configuration with built-in formatting
11+
2. Configuration is executed in buildkit, the execution engine at the heart of Docker
12+
13+
This makes any CI environment with Docker pre-installed work with Dagger out of the box.
14+
We started with [CI environments that you told us you are using](https://github.com/dagger/dagger/discussions/1677).
15+
We will configure a production deployment for the same application that we covered in the previous page.
16+
17+
:::note
18+
If you cannot find your CI environment below, [let us know via this GitHub discussion](https://github.com/dagger/dagger/discussions/1677).
19+
:::
20+
821
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
922

1023
<Tabs defaultValue="github-actions"
@@ -13,23 +26,70 @@ values={[
1326
{label: 'GitHub Actions', value: 'github-actions'},
1427
{label: 'CircleCI', value: 'circleci'},
1528
{label: 'GitLab', value: 'gitlab'},
29+
{label: 'Jenkins', value: 'jenkins'},
30+
{label: 'Tekton', value: 'tekton'},
1631
]}>
1732

1833
<TabItem value="github-actions">
1934

20-
Since Dagger early access required a GitHub account, GitHub Actions seems like a reasonable starting point.
35+
`.github/workflows/todoapp.yml`
36+
37+
```yaml
38+
name: todoapp
39+
40+
push:
41+
# Trigger this workflow only on commits pushed to the main branch
42+
branches:
43+
- main
44+
45+
# Dagger plan gets configured via client environment variables
46+
env:
47+
# This needs to be unique across all of netlify.app
48+
APP_NAME: todoapp-dagger-europa
49+
NETLIFY_TEAM: dagger
50+
# https://app.netlify.com/user/applications/personal
51+
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
52+
DAGGER_LOG_FORMAT: plain
53+
54+
jobs:
55+
dagger:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Clone repository
59+
uses: actions/checkout@v2
60+
61+
- name: Deploy to Netlify
62+
# https://github.com/dagger/dagger-for-github
63+
uses: dagger/[email protected]
64+
with:
65+
workdir: pkg/universe.dagger.io/examples/todoapp
66+
plan: .
67+
do: deploy
68+
```
2169
2270
</TabItem>
2371
2472
<TabItem value="circleci">
2573
26-
If you would like us to document this CI environment next, mention it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677)
74+
If you would like us to document CircleCI next, vote for it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677)
2775
2876
</TabItem>
2977
3078
<TabItem value="gitlab">
3179
32-
If you would like us to document this CI environment next, mention it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677)
80+
If you would like us to document GitLab next, vote for it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677)
81+
82+
</TabItem>
83+
84+
<TabItem value="jenkins">
85+
86+
If you would like us to document Jenkins next, vote for it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677)
87+
88+
</TabItem>
89+
90+
<TabItem value="tekton">
91+
92+
If you would like us to document Tekton next, vote for it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677)
3393
3494
</TabItem>
3595
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Todo APP
2+
3+
[Dagger documentation website](https://docs.dagger.io/)

pkg/universe.dagger.io/examples/todoapp/base.cue

Lines changed: 0 additions & 28 deletions
This file was deleted.

pkg/universe.dagger.io/examples/todoapp/dev/dev.cue

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package netlify
2+
3+
import (
4+
"dagger.io/dagger"
5+
"universe.dagger.io/alpine"
6+
"universe.dagger.io/bash"
7+
"universe.dagger.io/docker"
8+
"universe.dagger.io/netlify"
9+
)
10+
11+
dagger.#Plan & {
12+
client: {
13+
filesystem: {
14+
".": read: {
15+
contents: dagger.#FS
16+
exclude: [
17+
"README.md",
18+
"build",
19+
"netlify.cue",
20+
"node_modules",
21+
]
22+
}
23+
build: write: contents: actions.build.contents.output
24+
}
25+
env: {
26+
APP_NAME: string
27+
NETLIFY_TEAM: string
28+
NETLIFY_TOKEN: dagger.#Secret
29+
}
30+
}
31+
actions: {
32+
deps: docker.#Build & {
33+
steps: [
34+
alpine.#Build & {
35+
packages: {
36+
bash: {}
37+
yarn: {}
38+
git: {}
39+
}
40+
},
41+
docker.#Copy & {
42+
contents: client.filesystem.".".read.contents
43+
dest: "/src"
44+
},
45+
// bash.#Run is a superset of docker.#Run
46+
// install yarn dependencies
47+
bash.#Run & {
48+
workdir: "/src"
49+
mounts: "/cache/yarn": dagger.#Mount & {
50+
dest: "/cache/yarn"
51+
type: "cache"
52+
contents: dagger.#CacheDir & {
53+
id: "todoapp-yarn-cache"
54+
}
55+
}
56+
script: contents: #"""
57+
yarn config set cache-folder /cache/yarn
58+
yarn install
59+
"""#
60+
},
61+
]
62+
}
63+
64+
test: bash.#Run & {
65+
input: deps.output
66+
workdir: "/src"
67+
script: contents: #"""
68+
yarn run test
69+
"""#
70+
}
71+
72+
build: {
73+
run: bash.#Run & {
74+
input: test.output
75+
workdir: "/src"
76+
script: contents: #"""
77+
yarn run build
78+
"""#
79+
}
80+
81+
contents: dagger.#Subdir & {
82+
input: run.output.rootfs
83+
path: "/src/build"
84+
}
85+
}
86+
87+
deploy: netlify.#Deploy & {
88+
contents: build.contents.output
89+
site: client.env.APP_NAME
90+
token: client.env.NETLIFY_TOKEN
91+
team: client.env.NETLIFY_TEAM
92+
}
93+
}
94+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "moz-todo-react",
3+
"version": "0.1.0",
4+
"private": true,
5+
"homepage": "./",
6+
"dependencies": {
7+
"@testing-library/jest-dom": "^4.2.4",
8+
"@testing-library/react": "^9.3.2",
9+
"@testing-library/user-event": "^7.1.2",
10+
"gh-pages": "^3.2.3",
11+
"nanoid": "^3.1.3",
12+
"react": "^16.13.1",
13+
"react-dom": "^16.13.1",
14+
"react-scripts": "3.4.1"
15+
},
16+
"scripts": {
17+
"start": "react-scripts start",
18+
"build": "react-scripts build",
19+
"test": "react-scripts test --watchAll=false --passWithNoTests",
20+
"gh-pages": "gh-pages -d build -u 'github-actions-bot <[email protected]>'",
21+
"eject": "react-scripts eject"
22+
},
23+
"eslintConfig": {
24+
"extends": "react-app"
25+
},
26+
"browserslist": {
27+
"production": [
28+
">0.2%",
29+
"not dead",
30+
"not op_mini all"
31+
],
32+
"development": [
33+
"last 1 chrome version",
34+
"last 1 firefox version",
35+
"last 1 safari version"
36+
]
37+
}
38+
}
3.08 KB
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
manifest.json provides metadata used when your web app is installed on a
15+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
-->
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>My Todo app</title>
28+
</head>
29+
<body>
30+
<noscript>You need to enable JavaScript to run this app.</noscript>
31+
<div id="root"></div>
32+
<!--
33+
This HTML file is a template.
34+
If you open it directly in the browser, you will see an empty page.
35+
36+
You can add webfonts, meta tags, or analytics to this file.
37+
The build step will place the bundled scripts into the <body> tag.
38+
39+
To begin the development, run `npm start` or `yarn start`.
40+
To create a production bundle, use `npm run build` or `yarn build`.
41+
-->
42+
</body>
43+
</html>

0 commit comments

Comments
 (0)