Apply Solomon comments on universe.dagger.io/go
- Improve #Container with a better docker.#Run integration - Supports concurrency caching in #Container - Simplify code maintainability and readability - Simplify binary export in #Build - Support multi binary building - External #Version management Signed-off-by: Vasek - Tom C <tom.chauveau@epitech.eu>
This commit is contained in:
committed by
Vasek - Tom C
parent
e49bb34e87
commit
2887139bf7
@@ -2,14 +2,10 @@ package go
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/engine"
|
||||
)
|
||||
|
||||
// Build a go binary
|
||||
#Build: {
|
||||
// Go version to use
|
||||
version: *#Image.version | string
|
||||
|
||||
// Source code
|
||||
source: dagger.#FS
|
||||
|
||||
@@ -28,24 +24,27 @@ import (
|
||||
// LDFLAGS to use for linking
|
||||
ldflags: *"" | string
|
||||
|
||||
// Target binary output
|
||||
output: string
|
||||
|
||||
env: [string]: string
|
||||
|
||||
_build: #Container & {
|
||||
"version": version
|
||||
"source": source
|
||||
"env": env
|
||||
args: ["build", "-v", "-tags", tags, "-ldflags", ldflags, "-o", output, package]
|
||||
container: #Container & {
|
||||
"source": source
|
||||
"env": env
|
||||
command: {
|
||||
args: [package]
|
||||
flags: {
|
||||
build: true
|
||||
"-v": true
|
||||
"-tags": tags
|
||||
"-ldflags": ldflags
|
||||
"-o": "/output/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_copy: engine.#Copy & {
|
||||
input: engine.#Scratch
|
||||
contents: _build.output.rootfs
|
||||
source: output
|
||||
dest: output
|
||||
_binary: dagger.#Subdir & {
|
||||
input: container.output.rootfs
|
||||
path: "/output"
|
||||
}
|
||||
|
||||
binary: _copy.output
|
||||
binary: _binary.output
|
||||
}
|
||||
|
Reference in New Issue
Block a user