universe: go: improve cache management
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
f90b1ad079
commit
3e8c9379b5
@ -38,6 +38,7 @@ import (
|
||||
}
|
||||
}
|
||||
command: {
|
||||
name: "go"
|
||||
args: [package]
|
||||
flags: {
|
||||
build: true
|
||||
|
@ -18,25 +18,31 @@ import (
|
||||
// Use go image
|
||||
_image: #Image
|
||||
|
||||
_sourcePath: "/src"
|
||||
_cachePath: "/root/.cache/gocache"
|
||||
_sourcePath: "/src"
|
||||
_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
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ package go
|
||||
|
||||
#Container & {
|
||||
command: {
|
||||
name: "go"
|
||||
args: [package]
|
||||
flags: {
|
||||
test: true
|
||||
|
@ -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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user