Add node_modules mount to improve caching times
This commit adds `node_modules` to dagger run commands so cached builds have similar speed times as running commands locally directly through yarn <script> Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
parent
69b4845d2e
commit
6344bb020b
@ -8,6 +8,15 @@ import (
|
||||
"universe.dagger.io/netlify"
|
||||
)
|
||||
|
||||
nodeModulesMount: "/src/node_modules": dagger.#Mount & {
|
||||
dest: "/src/node_modules"
|
||||
type: "cache"
|
||||
contents: dagger.#CacheDir & {
|
||||
id: "todoapp-modules-cache"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dagger.#Plan & {
|
||||
client: {
|
||||
filesystem: {
|
||||
@ -46,13 +55,16 @@ dagger.#Plan & {
|
||||
// install yarn dependencies
|
||||
bash.#Run & {
|
||||
workdir: "/src"
|
||||
mounts: "/cache/yarn": dagger.#Mount & {
|
||||
mounts: {
|
||||
"/cache/yarn": dagger.#Mount & {
|
||||
dest: "/cache/yarn"
|
||||
type: "cache"
|
||||
contents: dagger.#CacheDir & {
|
||||
id: "todoapp-yarn-cache"
|
||||
}
|
||||
}
|
||||
nodeModulesMount
|
||||
}
|
||||
script: contents: #"""
|
||||
yarn config set cache-folder /cache/yarn
|
||||
yarn install
|
||||
@ -64,6 +76,7 @@ dagger.#Plan & {
|
||||
test: bash.#Run & {
|
||||
input: deps.output
|
||||
workdir: "/src"
|
||||
mounts: nodeModulesMount
|
||||
script: contents: #"""
|
||||
yarn run test
|
||||
"""#
|
||||
@ -72,6 +85,7 @@ dagger.#Plan & {
|
||||
build: {
|
||||
run: bash.#Run & {
|
||||
input: test.output
|
||||
mounts: nodeModulesMount
|
||||
workdir: "/src"
|
||||
script: contents: #"""
|
||||
yarn run build
|
||||
|
Reference in New Issue
Block a user