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: { command: {
name: "go"
args: [package] args: [package]
flags: { flags: {
build: true build: true

View File

@ -19,24 +19,30 @@ import (
_image: #Image _image: #Image
_sourcePath: "/src" _sourcePath: "/src"
_cachePath: "/root/.cache/gocache" _modCachePath: "/root/.cache/go-mod"
_buildCachePath: "/root/.cache/go-build"
docker.#Run & { docker.#Run & {
input: *_image.output | docker.#Image input: *_image.output | docker.#Image
workdir: "/src" workdir: _sourcePath
command: name: "go"
mounts: { mounts: {
"source": { "source": {
dest: _sourcePath dest: _sourcePath
contents: source contents: source
} }
"go assets cache": { "go mod cache": {
contents: core.#CacheDir & { 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 & { #Container & {
command: { command: {
name: "go"
args: [package] args: [package]
flags: { flags: {
test: true test: true

View File

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