dev.cue: polish

Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
Solomon Hykes 2021-04-06 20:52:06 +00:00
parent 299a38c6b1
commit d522fc3396
2 changed files with 48 additions and 16 deletions

15
dev.cue
View File

@ -8,6 +8,7 @@ import (
// Dagger source code // Dagger source code
source: dagger.#Artifact source: dagger.#Artifact
// Build the dagger binaries
build: #Container & { build: #Container & {
image: #ImageFromRef & {ref: "docker.io/golang:1.16-alpine"} image: #ImageFromRef & {ref: "docker.io/golang:1.16-alpine"}
@ -15,6 +16,11 @@ build: #Container & {
"apk add --no-cache file", "apk add --no-cache file",
] ]
command: """
go test -v ./...
go build -o /binaries/ ./cmd/...
"""
volume: { volume: {
daggerSource: { daggerSource: {
from: source from: source
@ -36,20 +42,17 @@ build: #Container & {
dir: "/src" dir: "/src"
outputDir: "/binaries" outputDir: "/binaries"
command: """
go test -v ./...
go build -o /binaries/ ./cmd/...
"""
} }
// Execute `dagger help`
usage: #Container & { usage: #Container & {
image: alpine.#Image image: alpine.#Image
command: "dagger help"
volume: binaries: { volume: binaries: {
from: build from: build
dest: "/usr/local/dagger/bin/" dest: "/usr/local/dagger/bin/"
} }
shell: search: "/usr/local/dagger/bin": true shell: search: "/usr/local/dagger/bin": true
command: "dagger help"
} }

View File

@ -1,3 +1,5 @@
// docker: build and run Docker containers
// https://docker.com
package main package main
import ( import (
@ -39,18 +41,48 @@ import (
] ]
} }
// Run a Docker container
#Container: { #Container: {
// Container image
image: dagger.#Artifact image: dagger.#Artifact
// Optional setup scripts // Independently cacheable setup commands
setup: [...string] setup: [...string]
// Command to execute
command: string
// Environment variables shared by all commands // Environment variables shared by all commands
env: [string]: string env: [string]: string
// Directory in which the command is executed
dir: string | *"/"
// Directory to expose as the output.
// By default the root filesystem is the output.
outputDir: string | *"/"
// If true, the command is never cached.
// (false by default).
always: true | *false
// External volumes. There are 4 types:
//
// 1. "mount": mount any artifact.
// Changes are not included in the final output.
//
// 2. "copy": copy any artifact.
// Changes are included in the final output.
//
// 3. "tmpfs": create a temporary directory.
//
// 4. "cache": create a persistent cache diretory.
//
volume: [name=string]: { volume: [name=string]: {
// Destination path
dest: string | *"/" dest: string | *"/"
*{ *{
type: "mount" type: "mount"
from: dagger.#Artifact from: dagger.#Artifact
@ -64,9 +96,15 @@ import (
} }
} }
// Configure the shell which executes all commands.
shell: { shell: {
// Path of the shell to execute
path: string | *"/bin/sh" path: string | *"/bin/sh"
// Arguments to pass to the shell prior to the command
args: [...string] | *["-c"] args: [...string] | *["-c"]
// Map of directories to search for commands
// In POSIX shells this is used to generate the $PATH
// environment variable.
search: [string]: bool search: [string]: bool
search: { search: {
"/sbin": true "/sbin": true
@ -79,15 +117,6 @@ import (
} }
env: PATH: string | *strings.Join([ for p, v in shell.search if v {p}], ":") env: PATH: string | *strings.Join([ for p, v in shell.search if v {p}], ":")
command: string
dir: string | *"/"
env: [string]: string
outputDir: string | *"/"
always: true | *false
#up: [ #up: [
op.#Load & {from: image}, op.#Load & {from: image},
// Copy volumes with type=copy // Copy volumes with type=copy