-
Notifications
You must be signed in to change notification settings - Fork 854
Europa docs: From local dev to CI environment #1693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: todoapp | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - '.github/workflows/todoapp.yml' | ||
| - 'pkg/universe.dagger.io/examples/todoapp/**' | ||
|
|
||
| env: | ||
| # This needs to be unique across all of Netlify | ||
| APP_NAME: todoapp-dagger-europa | ||
| NETLIFY_TEAM: blocklayer | ||
| # https://app.netlify.com/user/applications/personal | ||
| NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }} | ||
| DAGGER_LOG_FORMAT: plain | ||
|
|
||
| jobs: | ||
| dagger: | ||
| name: "Deploy todoapp to Netlify" | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: "Clone repository" | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # TODO: maybe use Dagger action post 0.2.0-beta.1 | ||
| - name: "Setup Go" | ||
| uses: actions/setup-go@v1 | ||
| with: | ||
| go-version: 1.16 | ||
|
|
||
| - name: "Install dev Dagger" | ||
| run: | | ||
| make dagger | ||
|
|
||
| - name: "Dagger" | ||
| run: | | ||
| cd pkg/universe.dagger.io/examples/todoapp | ||
| ${{ github.workspace }}/cmd/dagger/dagger do deploy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,19 @@ displayed_sidebar: europa | |
|
|
||
| # From local dev to CI environment | ||
|
|
||
| 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: | ||
|
|
||
| 1. Instead of YAML you write CUE: typed configuration with built-in formatting | ||
| 2. Configuration is executed in buildkit, the execution engine at the heart of Docker | ||
|
|
||
| This makes any CI environment with Docker pre-installed work with Dagger out of the box. | ||
| We started with [CI environments that you told us you are using](https://github.com/dagger/dagger/discussions/1677). | ||
| We will configure a production deployment for the same application that we covered in the previous page. | ||
|
|
||
| :::note | ||
| If you cannot find your CI environment below, [let us know via this GitHub discussion](https://github.com/dagger/dagger/discussions/1677). | ||
| ::: | ||
|
|
||
| import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; | ||
|
|
||
| <Tabs defaultValue="github-actions" | ||
|
|
@@ -13,23 +26,70 @@ values={[ | |
| {label: 'GitHub Actions', value: 'github-actions'}, | ||
| {label: 'CircleCI', value: 'circleci'}, | ||
| {label: 'GitLab', value: 'gitlab'}, | ||
| {label: 'Jenkins', value: 'jenkins'}, | ||
| {label: 'Tekton', value: 'tekton'}, | ||
| ]}> | ||
|
|
||
| <TabItem value="github-actions"> | ||
|
|
||
| Since Dagger early access required a GitHub account, GitHub Actions seems like a reasonable starting point. | ||
| `.github/workflows/todoapp.yml` | ||
|
|
||
| ```yaml | ||
| name: todoapp | ||
|
|
||
| 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 | ||
| # https://app.netlify.com/user/applications/personal | ||
| NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }} | ||
| DAGGER_LOG_FORMAT: plain | ||
|
|
||
| jobs: | ||
| dagger: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Clone repository | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Deploy to Netlify | ||
| # https://github.com/dagger/dagger-for-github | ||
| uses: dagger/[email protected] | ||
| with: | ||
| workdir: pkg/universe.dagger.io/examples/todoapp | ||
| plan: . | ||
| do: deploy | ||
| ``` | ||
|
|
||
| </TabItem> | ||
|
|
||
| <TabItem value="circleci"> | ||
|
|
||
| If you would like us to document this CI environment next, mention it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677) | ||
| If you would like us to document CircleCI next, vote for it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677) | ||
|
|
||
| </TabItem> | ||
|
|
||
| <TabItem value="gitlab"> | ||
|
|
||
| If you would like us to document this CI environment next, mention it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677) | ||
| If you would like us to document GitLab next, vote for it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677) | ||
|
|
||
| </TabItem> | ||
|
|
||
| <TabItem value="jenkins"> | ||
|
|
||
| If you would like us to document Jenkins next, vote for it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677) | ||
|
|
||
| </TabItem> | ||
|
|
||
| <TabItem value="tekton"> | ||
|
|
||
| If you would like us to document Tekton next, vote for it here: [dagger#1677](https://github.com/dagger/dagger/discussions/1677) | ||
|
|
||
| </TabItem> | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Todo APP | ||
|
|
||
| [Dagger documentation website](https://docs.dagger.io/) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| package netlify | ||
|
|
||
| import ( | ||
| "dagger.io/dagger" | ||
| "universe.dagger.io/alpine" | ||
| "universe.dagger.io/bash" | ||
| "universe.dagger.io/docker" | ||
| "universe.dagger.io/netlify" | ||
| ) | ||
|
|
||
| dagger.#Plan & { | ||
| client: { | ||
| filesystem: { | ||
| ".": read: { | ||
| contents: dagger.#FS | ||
| exclude: [ | ||
| "README.md", | ||
| "build", | ||
| "netlify.cue", | ||
| "node_modules", | ||
| ] | ||
| } | ||
| build: write: contents: actions.build.contents.output | ||
| } | ||
| env: { | ||
| APP_NAME: string | ||
| NETLIFY_TEAM: string | ||
| NETLIFY_TOKEN: dagger.#Secret | ||
| } | ||
| } | ||
| actions: { | ||
| deps: docker.#Build & { | ||
| steps: [ | ||
| alpine.#Build & { | ||
| packages: { | ||
| bash: {} | ||
| yarn: {} | ||
| git: {} | ||
| } | ||
| }, | ||
| docker.#Copy & { | ||
| contents: client.filesystem.".".read.contents | ||
| dest: "/src" | ||
| }, | ||
| // bash.#Run is a superset of docker.#Run | ||
| // install yarn dependencies | ||
| bash.#Run & { | ||
| workdir: "/src" | ||
| mounts: "/cache/yarn": dagger.#Mount & { | ||
| dest: "/cache/yarn" | ||
| type: "cache" | ||
| contents: dagger.#CacheDir & { | ||
| id: "todoapp-yarn-cache" | ||
| } | ||
| } | ||
| script: contents: #""" | ||
| yarn config set cache-folder /cache/yarn | ||
| yarn install | ||
| """# | ||
| }, | ||
| ] | ||
| } | ||
|
|
||
| test: bash.#Run & { | ||
| input: deps.output | ||
| workdir: "/src" | ||
| script: contents: #""" | ||
| yarn run test | ||
| """# | ||
| } | ||
|
|
||
| build: { | ||
| run: bash.#Run & { | ||
| input: test.output | ||
| workdir: "/src" | ||
| script: contents: #""" | ||
| yarn run build | ||
| """# | ||
| } | ||
|
|
||
| contents: dagger.#Subdir & { | ||
| input: run.output.rootfs | ||
| path: "/src/build" | ||
| } | ||
| } | ||
|
|
||
| deploy: netlify.#Deploy & { | ||
| contents: build.contents.output | ||
| site: client.env.APP_NAME | ||
| token: client.env.NETLIFY_TOKEN | ||
| team: client.env.NETLIFY_TEAM | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "name": "moz-todo-react", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "homepage": "./", | ||
| "dependencies": { | ||
| "@testing-library/jest-dom": "^4.2.4", | ||
| "@testing-library/react": "^9.3.2", | ||
| "@testing-library/user-event": "^7.1.2", | ||
| "gh-pages": "^3.2.3", | ||
| "nanoid": "^3.1.3", | ||
| "react": "^16.13.1", | ||
| "react-dom": "^16.13.1", | ||
| "react-scripts": "3.4.1" | ||
| }, | ||
| "scripts": { | ||
| "start": "react-scripts start", | ||
| "build": "react-scripts build", | ||
| "test": "react-scripts test --watchAll=false --passWithNoTests", | ||
| "gh-pages": "gh-pages -d build -u 'github-actions-bot <[email protected]>'", | ||
| "eject": "react-scripts eject" | ||
| }, | ||
| "eslintConfig": { | ||
| "extends": "react-app" | ||
| }, | ||
| "browserslist": { | ||
| "production": [ | ||
| ">0.2%", | ||
| "not dead", | ||
| "not op_mini all" | ||
| ], | ||
| "development": [ | ||
| "last 1 chrome version", | ||
| "last 1 firefox version", | ||
| "last 1 safari version" | ||
| ] | ||
| } | ||
| } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <meta name="theme-color" content="#000000" /> | ||
| <meta | ||
| name="description" | ||
| content="Web site created using create-react-app" | ||
| /> | ||
| <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
| <!-- | ||
| manifest.json provides metadata used when your web app is installed on a | ||
| user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
| --> | ||
| <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
| <!-- | ||
| Notice the use of %PUBLIC_URL% in the tags above. | ||
| It will be replaced with the URL of the `public` folder during the build. | ||
| Only files inside the `public` folder can be referenced from the HTML. | ||
|
|
||
| Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
| work correctly both with client-side routing and a non-root public URL. | ||
| Learn how to configure a non-root public URL by running `npm run build`. | ||
| --> | ||
| <title>My Todo app</title> | ||
| </head> | ||
| <body> | ||
| <noscript>You need to enable JavaScript to run this app.</noscript> | ||
| <div id="root"></div> | ||
| <!-- | ||
| This HTML file is a template. | ||
| If you open it directly in the browser, you will see an empty page. | ||
|
|
||
| You can add webfonts, meta tags, or analytics to this file. | ||
| The build step will place the bundled scripts into the <body> tag. | ||
|
|
||
| To begin the development, run `npm start` or `yarn start`. | ||
| To create a production bundle, use `npm run build` or `yarn build`. | ||
| --> | ||
| </body> | ||
| </html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, me too, but this seemed reasonable:
Even if Netlify does the right thing, we are still a private repository and pay for GitHub Actions build minutes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.