forked from docker/docker-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
95 lines (81 loc) · 2.62 KB
/
Taskfile.yml
File metadata and controls
95 lines (81 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
version: "3"
vars:
BINARY_NAME: cagent{{if eq OS "windows"}}.exe{{end}}
MAIN_PKG: ./main.go
BUILD_DIR: ./bin
GIT_TAG:
sh: git describe --tags --exact-match 2>/dev/null || echo dev
GIT_COMMIT:
sh: git rev-parse HEAD
GO_SOURCES: "**/*.go"
BUILD_ARGS: '--build-arg GIT_TAG="{{.GIT_TAG}}" --build-arg GIT_COMMIT="{{.GIT_COMMIT}}"'
LDFLAGS: '-X "github.com/docker/cagent/pkg/version.Version={{.GIT_TAG}}" -X "github.com/docker/cagent/pkg/version.Commit={{.GIT_COMMIT}}"'
tasks:
default:
cmd: task --list
dev:
deps: ["lint", "test", "build"]
build:
desc: Build the application binary
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o {{.BUILD_DIR}}/{{.BINARY_NAME}} {{.MAIN_PKG}}
sources:
- "{{.GO_SOURCES}}"
- "**/*.template"
- "**/*.txt"
- "go.mod"
- "go.sum"
generates:
- "{{.BUILD_DIR}}/{{.BINARY_NAME}}"
link:
desc: Creates a symlink to ~/bin
cmd: ln -sf {{.USER_WORKING_DIR}}/{{.BUILD_DIR}}/{{.BINARY_NAME}} {{.HOME}}/bin/{{.BINARY_NAME}}
lint:
desc: Run golangci-lint
cmd: golangci-lint run
sources:
- "{{.GO_SOURCES}}"
- ".golangci.yml"
format:
desc: Format code
cmd: golangci-lint fmt
sources:
- "{{.GO_SOURCES}}"
- ".golangci.yml"
test:
desc: Run tests
cmd: go test ./...
sources:
- "{{.GO_SOURCES}}"
- "**/*.txt"
build-local:
desc: Build binaries for local host platform
cmd: docker buildx build --target=local {{.BUILD_ARGS}} --platform local --output=./dist .
cross:
desc: Build binaries for multiple platforms
cmd: docker buildx build --target=cross {{.BUILD_ARGS}} --platform linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64,windows/arm64 --output=./dist .
build-image:
desc: Build Docker image
cmd: docker buildx build -t docker/cagent {{.BUILD_ARGS}} .
push-image:
desc: Build and Push Docker image
cmd: docker buildx build --push --platform linux/amd64,linux/arm64 -t docker/cagent {{.BUILD_ARGS}} .
push-agent:
desc: Build dockerized agent
internal: true
vars:
DOCKER_ID:
sh: curl -s --unix-socket ~/Library/Containers/com.docker.docker/Data/backend.sock http://_/registry/info | jq -r .id
deps: ["build"]
cmd: ./bin/cagent build --push ./examples/{{.AGENT}}.yaml {{.DOCKER_ID}}/cagent-{{.AGENT}}
push-agents:
desc: Build dockerized agents
deps:
- task: push-agent
vars: { AGENT: 'pirate' }
- task: push-agent
vars: { AGENT: 'github' }
- task: push-agent
vars: { AGENT: 'gopher' }
- task: push-agent
vars: { AGENT: 'mem' }