universe: go: improve cache management

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2022-03-31 19:19:15 -07:00
parent f90b1ad079
commit 3e8c9379b5
4 changed files with 24 additions and 10 deletions

View File

@ -38,6 +38,7 @@ import (
}
}
command: {
name: "go"
args: [package]
flags: {
build: true

View File

@ -19,24 +19,30 @@ import (
_image: #Image
_sourcePath: "/src"
_cachePath: "/root/.cache/gocache"
_modCachePath: "/root/.cache/go-mod"
_buildCachePath: "/root/.cache/go-build"
docker.#Run & {
input: *_image.output | docker.#Image
workdir: "/src"
command: name: "go"
workdir: _sourcePath
mounts: {
"source": {
dest: _sourcePath
contents: source
}
"go assets cache": {
"go mod cache": {
contents: core.#CacheDir & {
id: "\(name)_assets"
id: "\(name)_mod"
}
dest: _cachePath
dest: _modCachePath
}
"go build cache": {
contents: core.#CacheDir & {
id: "\(name)_build"
}
dest: _buildCachePath
}
}
env: GOMODCACHE: _cachePath
env: GOMODCACHE: _modCachePath
}
}

View File

@ -7,6 +7,7 @@ package go
#Container & {
command: {
name: "go"
args: [package]
flags: {
test: true

View File

@ -12,7 +12,10 @@ dagger.#Plan & {
simple: go.#Container & {
source: _source
command: args: ["version"]
command: {
name: "go"
args: ["version"]
}
}
override: {
@ -23,7 +26,10 @@ dagger.#Plan & {
command: go.#Container & {
input: base.output
source: _source
command: args: ["version"]
command: {
name: "go"
args: ["version"]
}
}
}
}