stdlib/js/react, stdlib/netlify: removed docker.#Container abstraction (gh issue #319)
Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
parent
e972863be6
commit
89882dbe81
@ -1,9 +1,11 @@
|
|||||||
package react
|
package react
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"dagger.io/dagger"
|
"dagger.io/dagger"
|
||||||
|
"dagger.io/dagger/op"
|
||||||
"dagger.io/alpine"
|
"dagger.io/alpine"
|
||||||
"dagger.io/docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// A ReactJS application
|
// A ReactJS application
|
||||||
@ -11,6 +13,13 @@ import (
|
|||||||
// Application source code
|
// Application source code
|
||||||
source: dagger.#Artifact
|
source: dagger.#Artifact
|
||||||
|
|
||||||
|
// Environment variables
|
||||||
|
env: [string]: string
|
||||||
|
|
||||||
|
// Write the contents of `environment` to this file,
|
||||||
|
// in the "envfile" format.
|
||||||
|
writeEnvFile: string | *""
|
||||||
|
|
||||||
// Yarn-specific settings
|
// Yarn-specific settings
|
||||||
yarn: {
|
yarn: {
|
||||||
// Read build output from this directory
|
// Read build output from this directory
|
||||||
@ -20,47 +29,50 @@ import (
|
|||||||
// Run this yarn script
|
// Run this yarn script
|
||||||
script: string | *"build"
|
script: string | *"build"
|
||||||
}
|
}
|
||||||
setup: [
|
|
||||||
"mkdir -p /cache/yarn",
|
|
||||||
]
|
|
||||||
|
|
||||||
// Build the application in a container, using yarn
|
build: #up: [
|
||||||
build: docker.#Container & {
|
op.#Load & {
|
||||||
image: alpine.#Image & {
|
from: alpine.#Image & {
|
||||||
package: bash: "=~5.1"
|
package: bash: "=~5.1"
|
||||||
package: yarn: "=~1.22"
|
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"
|
op.#Exec & {
|
||||||
// dest: "/cache/yarn"
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
outputDir: "/build"
|
|
||||||
shell: {
|
|
||||||
path: "/bin/bash"
|
|
||||||
args: [
|
args: [
|
||||||
|
"/bin/bash",
|
||||||
"--noprofile",
|
"--noprofile",
|
||||||
"--norc",
|
"--norc",
|
||||||
"-eo", "pipefail",
|
"-eo",
|
||||||
|
"pipefail",
|
||||||
"-c",
|
"-c",
|
||||||
|
"""
|
||||||
|
[ -n "$ENVFILE_NAME" ] && echo "$ENVFILE" > "$ENVFILE_NAME"
|
||||||
|
cat .env
|
||||||
|
yarn install --production false
|
||||||
|
yarn run "$YARN_BUILD_SCRIPT"
|
||||||
|
mv "$YARN_BUILD_DIRECTORY" /build
|
||||||
|
""",
|
||||||
]
|
]
|
||||||
}
|
if env != _|_ {
|
||||||
env: {
|
"env": env
|
||||||
YARN_BUILD_SCRIPT: yarn.script
|
}
|
||||||
YARN_CACHE_FOLDER: "/cache/yarn"
|
"env": {
|
||||||
YARN_BUILD_DIRECTORY: yarn.buildDir
|
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"
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package netlify
|
|||||||
import (
|
import (
|
||||||
"dagger.io/dagger"
|
"dagger.io/dagger"
|
||||||
"dagger.io/alpine"
|
"dagger.io/alpine"
|
||||||
"dagger.io/docker"
|
"dagger.io/dagger/op"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Netlify account
|
// A Netlify account
|
||||||
@ -42,52 +42,45 @@ import (
|
|||||||
// Logs URL for this deployment
|
// Logs URL for this deployment
|
||||||
logsUrl: string
|
logsUrl: string
|
||||||
|
|
||||||
// Deployment container
|
#up: [
|
||||||
#deploy: docker.#Container & {
|
op.#Load & {
|
||||||
image: alpine.#Image & {
|
from: alpine.#Image & {
|
||||||
package: {
|
package: bash: "=~5.1"
|
||||||
bash: "=~5.1"
|
package: jq: "=~1.6"
|
||||||
jq: "=~1.6"
|
package: curl: "=~7.74"
|
||||||
curl: "=~7.74"
|
package: yarn: "=~1.22"
|
||||||
yarn: "=~1.22"
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
setup: [
|
op.#Exec & {
|
||||||
"yarn global add netlify-cli@2.47.0",
|
args: ["yarn", "global", "add", "netlify-cli@2.47.0"]
|
||||||
]
|
},
|
||||||
shell: {
|
op.#Exec & {
|
||||||
path: "/bin/bash"
|
|
||||||
args: [
|
args: [
|
||||||
|
"/bin/bash",
|
||||||
"--noprofile",
|
"--noprofile",
|
||||||
"--norc",
|
"--norc",
|
||||||
"-eo",
|
"-eo",
|
||||||
"pipefail",
|
"pipefail",
|
||||||
"-c",
|
"-c",
|
||||||
|
#code,
|
||||||
]
|
]
|
||||||
}
|
env: {
|
||||||
dir: "/src"
|
NETLIFY_SITE_NAME: name
|
||||||
volume: "contents": {
|
if (create) {
|
||||||
dest: "/src"
|
NETLIFY_SITE_CREATE: "1"
|
||||||
from: contents
|
}
|
||||||
}
|
if customDomain != _|_ {
|
||||||
env: {
|
NETLIFY_DOMAIN: customDomain
|
||||||
NETLIFY_SITE_NAME: name
|
}
|
||||||
if (create) {
|
NETLIFY_ACCOUNT: account.name
|
||||||
NETLIFY_SITE_CREATE: "1"
|
NETLIFY_AUTH_TOKEN: account.token
|
||||||
}
|
}
|
||||||
if customDomain != _|_ {
|
dir: "/src"
|
||||||
NETLIFY_DOMAIN: customDomain
|
mount: "/src": from: contents
|
||||||
}
|
},
|
||||||
NETLIFY_ACCOUNT: account.name
|
op.#Export & {
|
||||||
NETLIFY_AUTH_TOKEN: account.token
|
|
||||||
}
|
|
||||||
export: {
|
|
||||||
source: "/output.json"
|
source: "/output.json"
|
||||||
format: "json"
|
format: "json"
|
||||||
}
|
},
|
||||||
}
|
]
|
||||||
|
|
||||||
// FIXME: this is a hack to use docker.#Container while exporting
|
|
||||||
// values.
|
|
||||||
#up: #deploy.#up
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package netlify
|
package netlify
|
||||||
|
|
||||||
#Site: #deploy: command: #"""
|
#code: #"""
|
||||||
create_site() {
|
create_site() {
|
||||||
url="https://api.netlify.com/api/v1/${NETLIFY_ACCOUNT:-}/sites"
|
url="https://api.netlify.com/api/v1/${NETLIFY_ACCOUNT:-}/sites"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user