stdlib: os package

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes
2021-05-06 06:53:04 +00:00
parent d93a1d24b8
commit 98b3951c73
12 changed files with 193 additions and 232 deletions

View File

@@ -4,11 +4,12 @@ import (
"strings"
"dagger.io/dagger"
"dagger.io/dagger/op"
"dagger.io/alpine"
"dagger.io/os"
)
// A ReactJS application
// FIXME: move this to a 'yarn' package for clarity
#App: {
// Application source code
source: dagger.#Artifact
@@ -30,48 +31,36 @@ import (
script: string | *"build"
}
build: #up: [
op.#Load & {
from: alpine.#Image & {
package: bash: "=~5.1"
package: yarn: "=~1.22"
build: os.#Dir & {
from: ctr
path: "/build"
}
ctr: os.#Container & {
image: alpine.#Image & {
package: {
bash: "=~5.1"
yarn: "=~1.22"
}
},
op.#Exec & {
args: [
"/bin/bash",
"--noprofile",
"--norc",
"-eo",
"pipefail",
"-c",
"""
[ -n "$ENVFILE_NAME" ] && echo "$ENVFILE" > "$ENVFILE_NAME"
yarn install --production false
yarn run "$YARN_BUILD_SCRIPT"
mv "$YARN_BUILD_DIRECTORY" /build
""",
]
if env != _|_ {
"env": env
}
shell: path: "/bin/bash"
command: """
[ -n "$ENVFILE_NAME" ] && echo "$ENVFILE" > "$ENVFILE_NAME"
yarn install --production false
yarn run "$YARN_BUILD_SCRIPT"
mv "$YARN_BUILD_DIRECTORY" /build
"""
"env": env & {
YARN_BUILD_SCRIPT: yarn.script
YARN_CACHE_FOLDER: "/cache/yarn"
YARN_BUILD_DIRECTORY: yarn.buildDir
if writeEnvFile != "" {
ENVFILE_NAME: writeEnvFile
ENVFILE: strings.Join([ for k, v in env {"\(k)=\(v)"}], "\n")
}
"env": {
YARN_BUILD_SCRIPT: yarn.script
YARN_CACHE_FOLDER: "/cache/yarn"
YARN_BUILD_DIRECTORY: yarn.buildDir
if writeEnvFile != "" {
ENVFILE_NAME: writeEnvFile
ENVFILE: strings.Join([ for k, v in env {"\(k)=\(v)"}], "\n")
}
}
dir: "/src"
mount: {
"/src": from: source
"/cache/yarn": "cache"
}
},
op.#Subdir & {
dir: "/build"
},
]
}
dir: "/src"
mount: "/src": from: source
cache: "/cache/yarn": true
}
}