stdlib: dagger.io/js/react
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
@@ -38,7 +38,7 @@ package op
|
||||
|
||||
#Subdir: {
|
||||
do: "subdir"
|
||||
dir: string | *"/"
|
||||
dir: string
|
||||
}
|
||||
|
||||
#Exec: {
|
||||
|
66
stdlib/js/react/react.cue
Normal file
66
stdlib/js/react/react.cue
Normal file
@@ -0,0 +1,66 @@
|
||||
package react
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/alpine"
|
||||
"dagger.io/docker"
|
||||
)
|
||||
|
||||
// A ReactJS application
|
||||
#App: {
|
||||
// Application source code
|
||||
source: dagger.#Artifact
|
||||
|
||||
// Yarn-specific settings
|
||||
yarn: {
|
||||
// Read build output from this directory
|
||||
// (path must be relative to working directory).
|
||||
buildDir: string | *"build"
|
||||
|
||||
// Run this yarn script
|
||||
script: string | *"build"
|
||||
}
|
||||
setup: [
|
||||
"mkdir -p /cache/yarn",
|
||||
]
|
||||
|
||||
// Build the application in a container, using yarn
|
||||
build: docker.#Container & {
|
||||
image: alpine.#Image & {
|
||||
package: bash: "=~5.1"
|
||||
package: yarn: "=~1.22"
|
||||
}
|
||||
dir: "/src"
|
||||
command: """
|
||||
yarn install --production false
|
||||
yarn run "$YARN_BUILD_SCRIPT"
|
||||
mv "$YARN_BUILD_DIRECTORY" \(outputDir)
|
||||
"""
|
||||
volume: {
|
||||
src: {
|
||||
from: source
|
||||
dest: "/src"
|
||||
}
|
||||
// yarnCache: {
|
||||
// type: "cache"
|
||||
// dest: "/cache/yarn"
|
||||
// }
|
||||
}
|
||||
outputDir: "/build"
|
||||
shell: {
|
||||
path: "/bin/bash"
|
||||
args: [
|
||||
"--noprofile",
|
||||
"--norc",
|
||||
"-eo", "pipefail",
|
||||
"-c",
|
||||
]
|
||||
}
|
||||
env: {
|
||||
YARN_BUILD_SCRIPT: yarn.script
|
||||
YARN_CACHE_FOLDER: "/cache/yarn"
|
||||
YARN_BUILD_DIRECTORY: yarn.buildDir
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
package yarn
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/alpine"
|
||||
"dagger.io/dagger/op"
|
||||
)
|
||||
|
||||
// Yarn Script
|
||||
#Script: {
|
||||
// Source code of the javascript application
|
||||
source: dagger.#Artifact
|
||||
|
||||
// Run this yarn script
|
||||
run: string | *"build"
|
||||
|
||||
// Read build output from this directory
|
||||
// (path must be relative to working directory).
|
||||
buildDirectory: string | *"build"
|
||||
|
||||
// Set these environment variables during the build
|
||||
env?: [string]: string
|
||||
|
||||
#up: [
|
||||
op.#Load & {
|
||||
from: alpine.#Image & {
|
||||
package: bash: "=~5.1"
|
||||
package: yarn: "=~1.22"
|
||||
}
|
||||
},
|
||||
op.#Exec & {
|
||||
args: [
|
||||
"/bin/bash",
|
||||
"--noprofile",
|
||||
"--norc",
|
||||
"-eo",
|
||||
"pipefail",
|
||||
"-c",
|
||||
"""
|
||||
yarn install --production false
|
||||
yarn run "$YARN_BUILD_SCRIPT"
|
||||
mv "$YARN_BUILD_DIRECTORY" /build
|
||||
""",
|
||||
]
|
||||
if env != _|_ {
|
||||
"env": env
|
||||
}
|
||||
"env": {
|
||||
YARN_BUILD_SCRIPT: run
|
||||
YARN_CACHE_FOLDER: "/cache/yarn"
|
||||
YARN_BUILD_DIRECTORY: buildDirectory
|
||||
}
|
||||
dir: "/src"
|
||||
mount: {
|
||||
"/src": from: source
|
||||
"/cache/yarn": "cache"
|
||||
}
|
||||
},
|
||||
op.#Subdir & {
|
||||
dir: "/build"
|
||||
},
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user