WIP: Fix Europa yarn

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2022-01-13 17:43:34 -08:00
committed by Sam Alba
parent ed8bb3f91b
commit c7ffdf788f
11 changed files with 137 additions and 32 deletions

View File

@@ -7,7 +7,8 @@ import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/alpine"
// "universe.dagger.io/alpine"
"universe.dagger.io/docker"
"universe.dagger.io/bash"
)
@@ -30,28 +31,54 @@ import (
// Run this yarn script
script: string | *"build"
// Fix for shadowing issues
let yarnScript = script
// FIXME: `CacheDir` must be passed by the caller?
cache: engine.#CacheDir
// Optional arguments for the script
args: [...string] | *[]
// Secret variables
// FIXME: not implemented. Are they needed?
secrets: [string]: dagger.#Secret
// Yarn version
yarnVersion: *"=~1.22" | string
// FIXME: trouble getting docker.#Build to work (cueflow task dependencies not working)
alpine: docker.#Pull & {
source: "index.docker.io/alpine:3.13.5@sha256:69e70a79f2d41ab5d637de98c1e0b055206ba40a8145e7bddb55ccc04e13cf8f"
}
yarnImage: docker.#Run & {
image: alpine.image
script: """
apk add -U --no-cache bash yarn
"""
}
// Run yarn in a containerized build environment
command: bash.#Run & {
*{
image: (alpine.#Build & {
bash: version: "=~5.1"
yarn: version: yarnVersion
}).image
env: CUSTOM_IMAGE: "0"
} | {
env: CUSTOM_IMAGE: "1"
}
// FIXME: not working?
// *{
// _image: alpine.#Build & {
// packages: {
// bash: version: "=~5.1"
// yarn: version: yarnVersion
// }
// }
script: """
// image: _image.output
// env: CUSTOM_IMAGE: "0"
// } | {
// env: CUSTOM_IMAGE: "1"
// }
image: docker.#Image & yarnImage.output
script: #"""
# Create $ENVFILE_NAME file if set
[ -n "$ENVFILE_NAME" ] && echo "$ENVFILE" > "$ENVFILE_NAME"
@@ -60,12 +87,12 @@ import (
opts=( $(echo $YARN_ARGS) )
yarn --cwd "$YARN_CWD" run "$YARN_BUILD_SCRIPT" ${opts[@]}
mv "$YARN_BUILD_DIRECTORY" /build
"""
"""#
mounts: {
"yarn cache": {
dest: "/cache/yarn"
contents: engine.#CacheDir
contents: cache
}
"package source": {
dest: "/src"
@@ -74,10 +101,11 @@ import (
// FIXME: mount secrets
}
output: directories: "/build": _
// FIXME
directories: "/build": _
env: {
YARN_BUILD_SCRIPT: script
YARN_BUILD_SCRIPT: yarnScript
YARN_ARGS: strings.Join(args, "\n")
YARN_CACHE_FOLDER: "/cache/yarn"
YARN_CWD: cwd
@@ -92,5 +120,5 @@ import (
}
// The final contents of the package after build
output: command.output.directories."/build".contents
output: command.directories."/build".contents
}