Merge pull request #129 from dagger/react-netlify

example: Deploy React app to Netlify
This commit is contained in:
Andrea Luzzardi 2021-02-19 12:11:57 -08:00 committed by GitHub
commit e4245e4090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 26 deletions

View File

@ -0,0 +1,28 @@
package main
import (
"dagger.io/dagger"
"dagger.io/netlify"
"dagger.io/yarn"
)
repository: #dagger: compute: [
dagger.#FetchGit & {
remote: "https://github.com/kabirbaidhya/react-todo-app.git"
ref: "624041b17bd62292143f99bce474a0e3c2d2dd61"
},
]
todoApp: netlify.#Site & {
account: {
name: "blocklayer"
token: string // Fill using --input-string todoApp.account.token=XXX
}
name: "dagger-test"
contents: yarn.#Script & {
source: repository
run: "build"
}
}

View File

@ -1,6 +1,4 @@
// ACME platform: everything you need to develop and ship improvements to package simple
// the ACME clothing store.
package acme
import ( import (
"dagger.io/dagger" "dagger.io/dagger"

30
stdlib/alpine/alpine.cue Normal file
View File

@ -0,0 +1,30 @@
package alpine
import (
"dagger.io/dagger"
)
let defaultVersion = "3.13.2@sha256:a75afd8b57e7f34e4dad8d65e2c7ba2e1975c795ce1ee22fa34f8cf46f96a3be"
#Image: {
package: [string]: true | false | string
version: string | *defaultVersion
#dagger: compute: [
dagger.#FetchContainer & {
ref: "index.docker.io/alpine:\(version)"
},
for pkg, info in package {
if (info & true) != _|_ {
dagger.#Exec & {
args: ["apk", "add", "-U", "--no-cache", pkg]
}
}
if (info & string) != _|_ {
dagger.#Exec & {
args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"]
}
}
},
]
}

View File

@ -1,6 +1,9 @@
package netlify package netlify
import "dagger.io/dagger" import (
"dagger.io/dagger"
"dagger.io/alpine"
)
// A Netlify account // A Netlify account
#Account: { #Account: {
@ -34,20 +37,13 @@ import "dagger.io/dagger"
string string
#dagger: compute: [ #dagger: compute: [
dagger.#FetchContainer & { dagger.#Load & {
ref: "alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930" from: alpine.#Image & {
}, package: bash: "=5.1.0-r0"
dagger.#Exec & { package: jq: "=1.6-r1"
args: ["apk", "add", "-U", "--no-cache", "bash=5.1.0-r0"] package: curl: "=7.74.0-r0"
}, package: yarn: "=1.22.10-r0"
dagger.#Exec & { }
args: ["apk", "add", "-U", "--no-cache", "jq=1.6-r1"]
},
dagger.#Exec & {
args: ["apk", "add", "-U", "--no-cache", "curl=7.74.0-r0"]
},
dagger.#Exec & {
args: ["apk", "add", "-U", "--no-cache", "yarn=1.22.10-r0"]
}, },
dagger.#Exec & { dagger.#Exec & {
args: ["yarn", "global", "add", "netlify-cli@2.47.0"] args: ["yarn", "global", "add", "netlify-cli@2.47.0"]

View File

@ -2,6 +2,7 @@ package yarn
import ( import (
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/alpine"
) )
// Yarn Script // Yarn Script
@ -20,14 +21,11 @@ import (
env?: [string]: string env?: [string]: string
#dagger: compute: [ #dagger: compute: [
dagger.#FetchContainer & { dagger.#Load & {
ref: "alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930" from: alpine.#Image & {
}, package: bash: "=5.1.0-r0"
dagger.#Exec & { package: yarn: "=1.22.10-r0"
args: ["apk", "add", "-U", "--no-cache", "bash=5.1.0-r0"] }
},
dagger.#Exec & {
args: ["apk", "add", "-U", "--no-cache", "yarn=1.22.10-r0"]
}, },
dagger.#Exec & { dagger.#Exec & {
args: [ args: [

View File

@ -13,6 +13,13 @@ DAGGER_BINARY_ARGS="${DAGGER_BINARY_ARGS:---log-format json}"
read -ra DAGGER_BINARY_ARGS <<< "${DAGGER_BINARY_ARGS:-}" read -ra DAGGER_BINARY_ARGS <<< "${DAGGER_BINARY_ARGS:-}"
readonly DAGGER_BINARY_ARGS readonly DAGGER_BINARY_ARGS
test::examples() {
local dagger="$1"
test::one "Examples: simple" --stdout='{"www":{"listing":"simple.cue\n","source":{}}}' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir www.source="$d"/../examples/simple "$d"/../examples/simple
}
test::compute(){ test::compute(){
local dagger="$1" local dagger="$1"
@ -237,6 +244,8 @@ test::all(){
test::export "$dagger" test::export "$dagger"
test::input "$dagger" test::input "$dagger"
test::subdir "$dagger" test::subdir "$dagger"
test::examples "$dagger"
} }
case "${1:-all}" in case "${1:-all}" in