-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathTaskfile.yml
82 lines (72 loc) · 2.56 KB
/
Taskfile.yml
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
version: '3'
vars:
DOCKER: docker
DOCKER_BUILD_FLAGS: ''
DOCKER_REGISTRY: docker.io
DOCKER_REPO: wagga40/zircolite
RULES_URL: https://github.com/wagga40/Zircolite-Rules/archive/refs/heads/main.tar.gz
PLATFORMS: linux/amd64,linux/arm64
tasks:
default:
deps: [clean]
get-version:
desc: Get the version from zircolite.py
cmds:
- 'echo "Version: {{.VERSION}}"'
vars:
VERSION:
sh: |
cat zircolite.py | grep "version = \"" | cut -d'"' -f2
docker-build:
desc: Build the Docker image
preconditions:
- sh: command -v {{.DOCKER}}
msg: "Docker (https://docs.docker.com/install/) is required. Please install it first"
cmds:
- '{{.DOCKER}} image build --rm --tag {{.DOCKER_REPO}}:dev {{.DOCKER_BUILD_FLAGS}} .'
docker-build-multi-arch:
desc: Build the Docker image for multiple architectures
cmds:
- '{{.DOCKER}} image build --rm --tag {{.DOCKER_REPO}}:{{.VERSION}} --platform {{.PLATFORMS}} {{.DOCKER_BUILD_FLAGS}} .'
- '{{.DOCKER}} image build --rm --tag {{.DOCKER_REPO}}:latest --platform {{.PLATFORMS}} {{.DOCKER_BUILD_FLAGS}} .'
vars:
VERSION:
sh: |
cat zircolite.py | grep "version = \"" | cut -d'"' -f2
docker-push:
desc: Push the Docker image to docker hub
deps: [docker-build-multi-arch]
cmds:
- '{{.DOCKER}} image push {{.DOCKER_REGISTRY}}/{{.DOCKER_REPO}}:{{.VERSION}}'
- '{{.DOCKER}} image push {{.DOCKER_REGISTRY}}/{{.DOCKER_REPO}}:latest'
vars:
VERSION:
sh: |
cat zircolite.py | grep "version = \"" | cut -d'"' -f2
clean:
desc: Remove all default artifacts
cmds:
- rm -rf detected_events.json
- rm -rf ./tmp-*
- rm -f zircolite.log
- rm -f fields.json
- rm -f zircolite.tar
save:
desc: Save the Docker image to an archive
cmds:
- |
if ! command -v docker &> /dev/null; then
echo "Docker (https://docs.docker.com/install/) is required. Please install it first"
exit 1
fi
- '{{.DOCKER}} image save --output zircolite.tar {{.DOCKER_REGISTRY}}/{{.DOCKER_REPO}}:{{.DOCKER_TAG}}'
update-rules:
desc: Update default rulesets using Zircolite-Rules repository
preconditions:
- sh: command -v curl
msg: "curl is required. Please install it first"
prompt: "This task will overwrite the existing rulesets. Are you sure you want to continue?"
cmds:
- curl -sSL {{.RULES_URL}} | tar -xzf -
- defer: rm -rf Zircolite-Rules-main
- mv Zircolite-Rules-main/rules_*.json ./rules/