-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathTaskfile.yml
More file actions
341 lines (293 loc) · 8.74 KB
/
Taskfile.yml
File metadata and controls
341 lines (293 loc) · 8.74 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
version: '3'
vars:
CORE_DIR: core/
UI_DIR: ui/
DOCKMAN_IMAGE_BASE: dockman
# Directory for Go source commands
GO_CMD_DIR: cmd
# Directory for build output
BUILD_DIR: .build
tasks:
default:
desc: "Lists all available tasks"
cmds:
- task --list --sort=alphanumeric
lint:
desc: Lint project
dir: core
cmds:
- golangci-lint run ./...
site:
desc: Start dev website
dir: website
cmds:
- npm run start
dock:
desc: start a a temp dockman on latest tag for testing
cmds:
- task: dock:latest
dock:*:
desc: start a a temp dockman instance for testing
env:
ttg: "{{index .MATCH 0}}"
cmds:
- docker run --rm
-p 8822:8866
-v /var/run/docker.sock:/var/run/docker.sock
ghcr.io/ra341/dockman:{{.ttg}}
init:
desc: "Setup dockman dev environment should be run only once after cloning the project."
deps:
- init:build
- init:ui
- tidy
init:build:
desc: "Creates the build dir"
cmd: mkdir -p {{.BUILD_DIR}}
status:
# This command checks if the directory exists. If it does, the task is considered "up-to-date" and won't run.
- test -d {{.BUILD_DIR}}
init:ui:
desc: "calls npm i and builds the ui"
dir: "{{.UI_DIR}}"
cmds:
- task: ui:dep
- task: ui
local:
dir: core
cmds:
- task ui:b:server
- task go:b:server OUT_EXE=./dockman PROD=1
ui:
desc: "Build the latest web ui in {{.UI_DIR}}"
dir: "{{.UI_DIR}}"
cmds:
- npm run build
ui:page:*:
vars:
NATIVE_DIR: "{{.UI_DIR}}src/pages"
CMD_NAME: "{{index .MATCH 0}}"
cmds:
- mkdir -p {{ .NATIVE_DIR }}/{{ .CMD_NAME }}
- touch {{ .NATIVE_DIR }}/{{ .CMD_NAME }}/{{ .CMD_NAME }}.tsx
ui:dev:
desc: "npm run dev in {{.UI_DIR}}"
dir: "{{.UI_DIR}}"
cmds:
- npm run dev
ui:prev:
desc: "npm run dev in {{.UI_DIR}}"
dir: "{{.UI_DIR}}"
cmds:
- npm run preview
ui:dep:
desc: "calls npm install in {{.UI_DIR}}"
dir: "{{.UI_DIR}}"
cmds:
- npm i
ui:b:*:
dir: "{{.UI_DIR}}"
vars:
CMD: "{{index .MATCH 0}}"
OUT_DIR: ../{{.CORE_DIR}}{{.GO_CMD_DIR}}/{{.CMD}}
desc: "Builds ui and copies for embed binary. Usage: task ui:<go cmd target>"
sources:
- "**/*.ts"
- "**/*.tsx"
cmds:
- task: ui
- rm -rf {{.OUT_DIR}}/dist
- mkdir -p {{.OUT_DIR}}/dist
- cp -rf dist {{.OUT_DIR}}/
clean:
desc: "Removes all files in {{.BUILD_DIR}}"
cmds:
- rm -rf {{.BUILD_DIR}}/*
tidy:
desc: "Calls go mod tidy in {{.CORE_DIR}}"
dir: "{{.CORE_DIR}}"
cmds:
- go mod download
- go mod tidy -v -x
docs:
dir: website
cmds:
- npm run start
go:r:*:
vars:
CMD_NAME: "{{index .MATCH 0}}"
dir: '{{.BUILD_DIR}}/{{.CMD_NAME}}'
cmds:
- 'task go:b:{{.CMD_NAME}}'
- './{{.CMD_NAME}}'
go:d:*:
vars:
CMD_NAME: "{{index .MATCH 0}}"
dir: '{{.BUILD_DIR}}/{{.CMD_NAME}}'
cmds:
- 'task go:b:{{.CMD_NAME}}'
- 'dlv exec {{.CMD_NAME}} --headless --listen :2345 --api-version 2'
go:w:*:
vars:
CMD_NAME: "{{index .MATCH 0}}"
cmds:
- wgo -file .go task go:d:{{.CMD_NAME}}
go:b:*:
dir: "{{.CORE_DIR}}"
desc: "Builds a Go target. Usage: task go:<target>"
vars:
CMD_NAME: "{{index .MATCH 0}}"
EXE_EXT: '{{if eq OS "windows"}}.exe{{end}}'
DEFAULT_OUT: ../{{.BUILD_DIR}}/{{.CMD_NAME}}
OUT: '{{.OUT| default .DEFAULT_OUT}}'
DEFAULT_OUT_EXE: '{{.OUT}}/{{.CMD_NAME}}{{.EXE_EXT}}'
OUT_EXE: '{{.OUT_EXE| default .DEFAULT_OUT_EXE}}'
DEFAULT_BDCMD: build
BDCMD: '{{.BDCMD| default .DEFAULT_BDCMD}}'
INFO_PACKAGE: "github.com/RA341/dockman/internal/info"
VERSION:
sh: git describe --tags --abbrev=0 2>/dev/null || echo "canary"
COMMIT:
sh: git rev-parse HEAD
BUILD_DATE:
sh: date -u +'%Y-%m-%dT%H:%M:%SZ'
BRANCH:
sh: git rev-parse --abbrev-ref HEAD
LDFLAGS: >-
{{if .PROD}}-s -w{{end}}
-X {{.INFO_PACKAGE}}.Version={{.VERSION}}
-X {{.INFO_PACKAGE}}.CommitInfo={{.COMMIT}}
-X {{.INFO_PACKAGE}}.BuildDate={{.BUILD_DATE}}
-X {{.INFO_PACKAGE}}.Branch={{.BRANCH}}
sources:
- "**/*.go"
- "go.*"
summary: |
Builds the '{{.CMD_NAME}}' Go command.
Source: '{{.GO_CMD_DIR}}/{{.CMD_NAME}}'
Output: '{{.BUILD_DIR}}/{{.CMD_NAME}}{{.EXE_EXT}}'
cmds:
- '{{if eq .OUT_EXE .DEFAULT_OUT_EXE}} mkdir -p {{.OUT}} {{end}}'
- CGO_ENABLED=1 go {{.BDCMD}} -ldflags "{{.LDFLAGS}}" -v
{{if eq .BDCMD .DEFAULT_BDCMD}} -o {{ .OUT_EXE }} {{end}}
./{{.GO_CMD_DIR}}/{{.CMD_NAME}}
go:*:
dir: "{{.BUILD_DIR}}"
desc: "Builds and runs a Go target. Usage: task go:r:<target>"
vars:
CMD_NAME: "{{index .MATCH 0}}"
EXE_EXT: '{{if eq OS "windows"}}.exe{{end}}'
ARGS: '{{if eq .CMD_NAME "updater"}}
-cr={{.CMD_NAME}}/compose {{else}}
-conf={{.CMD_NAME}}/config
-cr={{.CMD_NAME}}/compose{{end}}'
cmds:
- task: go:b:{{.CMD_NAME}}
- ../{{.BUILD_DIR}}/{{.CMD_NAME}}/{{.CMD_NAME}}{{.EXE_EXT}}{{.ARGS}}
desk:
dir: "{{.BUILD_DIR}}"
desc: "Builds and runs a Go desktop target"
vars:
CMD_NAME: "desktop"
EXE_EXT: '{{if eq OS "windows"}}.exe{{end}}'
cmds:
- task -p desk:go desk:ui
desk:go:
desc: "Builds the electron package"
vars:
PROD: '{{.PROD}}'
OUT: '{{.OUT}}'
CMD_NAME: "desktop"
cmds:
- task ui:b:{{.CMD_NAME}} -f
- task go:b:{{.CMD_NAME}} PROD={{.PROD}} OUT_EXE={{.OUT}} -f
build:pkg:appimage:
desc: Build the Linux AppImage
vars:
APP_NAME: dockman
APP_DIR: "{{.BUILD_DIR}}/{{.APP_NAME}}.AppDir"
APPIMAGE: "{{.BUILD_DIR}}/appimagetool"
cmds:
- rm -rf {{.APP_DIR}}
- mkdir -p {{.APP_DIR}}/usr/bin
- task desk:ui OUT={{.TASK_DIR}}/{{.APP_DIR}}/usr/bin
- task desk:go OUT=../{{.APP_DIR}}/usr/bin/dockman PROD=1
# metadata
- cp pkg/appimage/dockman.desktop {{.APP_DIR}}/
- cp ui/public/dockman.svg {{.APP_DIR}}/{{.APP_NAME}}.png
# mandatory AppRun
- ln -sr {{.APP_DIR}}/usr/bin/{{.APP_NAME}} {{.APP_DIR}}/AppRun
# download appimagetool
- |
if [ ! -f {{.APPIMAGE}} ]; then
curl -Lo {{.APPIMAGE}} https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x {{.APPIMAGE}}
fi
- ARCH=x86_64 {{.APPIMAGE}} {{.APP_DIR}} {{.BUILD_DIR}}/dockman.Appimage
desk:ui:*:
dir: "{{.UI_DIR}}"
desc: "Builds the electron package"
vars:
CMD_NAME: "{{index .MATCH 0}}"
DEFAULT_OUT: ../{{.BUILD_DIR}}/{{.CMD_NAME}}
OUT: '{{.OUT| default .DEFAULT_OUT}}'
ELECTRON: '{{if eq OS "windows"}}win-unpacked{{else}}linux-unpacked{{end}}'
cmds:
- npm run desk:build
- 'mkdir -p {{.OUT}}'
- 'cp -r release/{{.ELECTRON}}/. {{.OUT}}/ui'
go:
desc: "Builds and runs the default Go target of develop. Usage: task go"
vars:
CMD_NAME: "develop"
cmds:
- task: go:{{.CMD_NAME}}
dk:
desc: "Builds and runs the main dockman image. Usage: task dk"
cmds:
- task dk:r
dk:b:
desc: "Builds the main dockman image for a specific target. Usage: task dk:b"
cmds:
- docker build . -f pkg/docker/Dockerfile -t {{.DOCKMAN_IMAGE_BASE}}
dk:r:
desc: "Builds and runs the main dockman image for a specific target. Usage: task dk:r:<target>"
cmds:
- task dk:b
- docker run --rm
-e TZ=America/New_York
-e PUID=1000
-e PGID=1000
-e DOCKMAN_LOG_LEVEL=debug
-e DOCKMAN_LOG_VERBOSE=true
-e DOCKMAN_LOG_HTTP=false
-e DOCKMAN_LOG_WARN=false
-e DOCKMAN_AUTH_ENABLE=false
-e DOCKMAN_AUTH_USERNAME=wow
-e DOCKMAN_AUTH_PASSWORD=wow
-e DOCKMAN_COMPOSE_ROOT=/.build/docker/compose
-v /var/run/docker.sock:/var/run/docker.sock
-v ./.build/docker/compose:/.build/docker/compose
-v ./.build/docker/config:/config
-p 8221:8866
{{.DOCKMAN_IMAGE_BASE}}
dk:up:
desc: "Builds the updater image. Usage: task dk:<target>"
vars:
UPDATER: "Dockerfile.updater"
IMAGE: "updater"
TARGET: "dev"
cmds:
- docker build -f {{.UPDATER}} . -t {{.DOCKMAN_IMAGE_BASE}}/{{.IMAGE}}:{{.TARGET}}
dk:upr:
desc: "Builds and runs the updater image. Usage: task dk:<target>"
vars:
UPDATER: "Dockerfile.updater"
IMAGE: "updater"
TARGET: "dev"
cmds:
- docker run -p 8869:8869 {{.DOCKMAN_IMAGE_BASE}}/{{.IMAGE}}:{{.TARGET}}
dk:prune:
desc: "Prune docker images."
cmds:
- docker image prune -f