@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user