Move prototype 69-dagger-archon to top-level
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
46
examples/olivier/cue.mod/pkg/dagger.cloud/alpine/alpine.cue
Normal file
46
examples/olivier/cue.mod/pkg/dagger.cloud/alpine/alpine.cue
Normal file
@@ -0,0 +1,46 @@
|
||||
package alpine
|
||||
|
||||
// Default version pinned to digest. Manually updated.
|
||||
let defaultDigest="sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436"
|
||||
|
||||
ref: string
|
||||
|
||||
// Match a combination of inputs 'version' and 'digest':
|
||||
*{
|
||||
// no version, no digest:
|
||||
ref: "index.docker.io/alpine@\(defaultDigest)"
|
||||
} | {
|
||||
// version, no digest
|
||||
version: string
|
||||
ref: "alpine:\(version)"
|
||||
} | {
|
||||
// digest, no version
|
||||
digest: string
|
||||
ref: "alpine@\(digest)"
|
||||
} | {
|
||||
// version and digest
|
||||
version: string
|
||||
digest: string
|
||||
ref: "alpine:\(version)@\(digest)"
|
||||
}
|
||||
|
||||
// Packages to install
|
||||
package: [string]: true | false | string
|
||||
|
||||
#dagger: compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
"ref": ref
|
||||
},
|
||||
for pkg, info in package {
|
||||
if (info & true) != _|_ {
|
||||
do: "exec"
|
||||
args: ["apk", "add", "-U", "--no-cache", pkg]
|
||||
}
|
||||
if (info & string) != _|_ {
|
||||
do: "exec"
|
||||
args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"]
|
||||
}
|
||||
},
|
||||
]
|
||||
|
145
examples/olivier/cue.mod/pkg/dagger.cloud/dagger/dagger.cue
Normal file
145
examples/olivier/cue.mod/pkg/dagger.cloud/dagger/dagger.cue
Normal file
@@ -0,0 +1,145 @@
|
||||
package dagger
|
||||
|
||||
// A DAG is the basic unit of programming in dagger.
|
||||
// It is a special kind of program which runs as a pipeline of computing nodes running in parallel,
|
||||
// instead of a sequence of operations to be run by a single node.
|
||||
//
|
||||
// It is a powerful way to automate various parts of an application delivery workflow:
|
||||
// build, test, deploy, generate configuration, enforce policies, publish artifacts, etc.
|
||||
//
|
||||
// The DAG architecture has many benefits:
|
||||
// - Because DAGs are made of nodes executing in parallel, they are easy to scale.
|
||||
// - Because all inputs and outputs are snapshotted and content-addressed, DAGs
|
||||
// can easily be made repeatable, can be cached aggressively, and can be replayed
|
||||
// at will.
|
||||
// - Because nodes are executed by the same container engine as docker-build, DAGs
|
||||
// can be developed using any language or technology capable of running in a docker.
|
||||
// Dockerfiles and docker images are natively supported for maximum compatibility.
|
||||
//
|
||||
// - Because DAGs are programmed declaratively with a powerful configuration language,
|
||||
// they are much easier to test, debug and refactor than traditional programming languages.
|
||||
//
|
||||
// To execute a DAG, the dagger runtime JIT-compiles it to a low-level format called
|
||||
// llb, and executes it with buildkit.
|
||||
// Think of buildkit as a specialized VM for running compute graphs; and dagger as
|
||||
// a complete programming environment for that VM.
|
||||
//
|
||||
// The tradeoff for all those wonderful features is that a DAG architecture cannot be used
|
||||
// for all software: only software than can be run as a pipeline.
|
||||
//
|
||||
|
||||
// A dagger component is a configuration value augmented
|
||||
// by scripts defining how to compute it, present it to a user,
|
||||
// encrypt it, etc.
|
||||
#Component: {
|
||||
#dagger: {
|
||||
// script to compute the value
|
||||
compute?: #Script
|
||||
|
||||
terminal?: {
|
||||
// Display a message when opening a terminal session
|
||||
greeting?: string
|
||||
command: [string]: #Script
|
||||
}
|
||||
// Configure how the component is incorporated to user settings.
|
||||
// Configure how the end-user can configure this component
|
||||
settings?: {
|
||||
// If not specified, scrape from comments
|
||||
title?: string
|
||||
description?: string
|
||||
// Disable user input, even if incomplete?
|
||||
hidden: true | *false
|
||||
ui: _ // insert here something which can be compiled to react-jsonschema-form
|
||||
// Show the cue default value to the user, as a default input value?
|
||||
showDefault: true | *false
|
||||
|
||||
// Insert information needed by:
|
||||
// 1) clients to encrypt
|
||||
// ie. web wizard, cli
|
||||
// 2) middleware to implement deicphering in the cuellb pipeline
|
||||
// eg. integration with clcoud KMS, Vault...
|
||||
//
|
||||
// 3) connectors to make sure secrets are preserved
|
||||
encrypt?: {
|
||||
pubkey: string
|
||||
cipher: string
|
||||
}
|
||||
}
|
||||
}
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Any component can be referenced as a directory, since
|
||||
// every dagger script outputs a filesystem state (aka a directory)
|
||||
#Dir: #Component
|
||||
|
||||
#Script: [...#Op]
|
||||
|
||||
// One operation in a script
|
||||
// #Op: #FetchContainer | #FetchGit | #Export | #Exec | #Copy | #Load
|
||||
#Op: #FetchContainer | #Export | #Exec
|
||||
|
||||
// Export a value from fs state to cue
|
||||
#Export: {
|
||||
do: "export"
|
||||
// Source path in the container
|
||||
source: string
|
||||
format: "json"|"yaml"|*"string"|"number"|"boolean"
|
||||
}
|
||||
|
||||
#Load: #LoadComponent| #LoadScript
|
||||
#LoadComponent: {
|
||||
do: "load"
|
||||
from: #Component
|
||||
}
|
||||
#LoadScript: {
|
||||
do: "load"
|
||||
from: #Script
|
||||
}
|
||||
|
||||
|
||||
#Exec: {
|
||||
do: "exec"
|
||||
args: [...string]
|
||||
mount?: [string]: #MountTmp | #MountCache | #MountComponent | #MountScript
|
||||
env: [string]: string
|
||||
dir: string | *"/"
|
||||
always: true | *false
|
||||
}
|
||||
|
||||
#MountTmp: "tmpfs"
|
||||
#MountCache: "cache"
|
||||
#MountComponent: {
|
||||
input: #Component
|
||||
path: string | *"/"
|
||||
}
|
||||
#MountScript: {
|
||||
input: #Script
|
||||
path: string | *"/"
|
||||
}
|
||||
|
||||
#FetchContainer: {
|
||||
do: "fetch-container"
|
||||
ref: string
|
||||
}
|
||||
|
||||
#FetchGit: {
|
||||
do: "fetch-git"
|
||||
remote: string
|
||||
ref: string
|
||||
}
|
||||
|
||||
#Copy: {
|
||||
do: "copy"
|
||||
input: #Script | #Component
|
||||
src: string | *"/"
|
||||
dest: string | *"/"
|
||||
}
|
||||
|
||||
|
||||
#TestScript: #Script & [
|
||||
{ do: "fetch-container", ref: "alpine:latest" },
|
||||
{ do: "exec", args: ["echo", "hello", "world" ], env: DEBUG: "1" }
|
||||
]
|
63
examples/olivier/example.cue
Normal file
63
examples/olivier/example.cue
Normal file
@@ -0,0 +1,63 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"dagger.cloud/alpine"
|
||||
)
|
||||
|
||||
test: {
|
||||
string
|
||||
#dagger: compute: [
|
||||
{ do: "load", from: alpine },
|
||||
{
|
||||
do: "copy"
|
||||
from: [
|
||||
{ do: "fetch-container", ref: alpine.ref },
|
||||
]
|
||||
dest: "/src"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
dir: "/src"
|
||||
args: ["sh", "-c", """
|
||||
ls -l > /tmp/out
|
||||
"""
|
||||
]
|
||||
},
|
||||
{
|
||||
do: "export"
|
||||
source: "/tmp/out"
|
||||
format: "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
www: {
|
||||
|
||||
// Domain where the site will be deployed (user input)
|
||||
domain: string
|
||||
|
||||
// URL after deployment (computed)
|
||||
url: {
|
||||
string & =~ "https://.*"
|
||||
|
||||
#dagger: {
|
||||
compute: [
|
||||
{ do: "load", from: alpine },
|
||||
{
|
||||
do: "exec"
|
||||
args: ["sh", "-c",
|
||||
"""
|
||||
echo 'deploying to netlify (not really)'
|
||||
echo 'https://\(domain)/foo' > /tmp/out
|
||||
"""
|
||||
]
|
||||
},
|
||||
{
|
||||
do: "export"
|
||||
source: "/tmp/out"
|
||||
format: "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
3
examples/olivier/values.cue
Normal file
3
examples/olivier/values.cue
Normal file
@@ -0,0 +1,3 @@
|
||||
package example
|
||||
|
||||
www: domain: "www.foobar.com"
|
Reference in New Issue
Block a user