-
Notifications
You must be signed in to change notification settings - Fork 14
/
taskfile.yml
102 lines (83 loc) · 2.62 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
version: '3'
vars:
EXE: sumitroajiprabowo/go-snmp-olt-zte-c320{{exeExt}}
tasks:
default:
cmds:
- task: dev
dev:
desc: Start the local environment
cmds:
- docker compose -f docker-compose.local.yaml up -d && air -c .air.toml
go-install:
cmds:
- go install {{.REPO}}
dl-deps:
desc: Install tools required to run/build this app
cmds:
- task: go-install
vars: { REPO: github.com/cosmtrek/air@latest }
- task: tidy
init:
desc: Initialize the environment
deps: [ dl-deps ]
tidy:
desc: Clean up dependencies
cmds:
- go mod tidy
app-build:
desc: Build the app binary
cmds:
- CGO_ENABLED=0 go build -o {{.EXE}} ./cmd/api/main.go
sources:
- ./**/*.go
generates:
- ./{{.EXE}}
build-image:
desc: Build the docker image
cmds:
- docker build -t {{.EXE}} .
push-image:
desc: Push docker image with tag latest with multi-arch support (linux/amd64, linux/arm64) to docker hub
cmds:
- docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 -t {{.EXE}}:latest -f Dockerfile .
pull-image:
desc: Pull docker image with tag latest with multi-arch support (linux/amd64, linux/arm64) from docker hub
cmds:
- docker pull {{.EXE}}:latest
docker-run:
desc: Run docker image with tag latest
cmds:
- docker network create local-dev
- docker run -d --name redis-container --network local-dev -p 6379:6379 redis:7.2
- docker run -d -p 8081:8081 --name go-snmp-olt-zte-c320 --network local-dev -e REDIS_HOST=redis-container -e REDIS_PORT=6379 -e REDIS_DB=0 -e REDIS_MIN_IDLE_CONNECTIONS=200 -e REDIS_POOL_SIZE=12000 -e REDIS_POOL_TIMEOUT=240 -e SNMP_HOST=192.168.213.174 -e SNMP_PORT=161 -e SNMP_COMMUNITY=homenetro {{.EXE}}:latest
docker-stop:
desc: Stop docker image with tag latest
cmds:
- docker stop go-snmp-olt-zte-c320 && docker stop redis-container
docker-remove:
desc: Remove docker image with tag latest
cmds:
- docker network rm local-dev && docker rm go-snmp-olt-zte-c320 && docker rm redis-container
up:
desc: Start the docker containers in the background
cmds:
- docker compose up -d
up-rebuild:
desc: Rebuild the docker containers
cmds:
- docker compose up -d --build
down:
desc: Stop and remove the docker containers
cmds:
- docker compose down
restart:
desc: Restart the docker containers
cmds:
- task: down
- task: up
rebuild:
desc: Rebuild the docker image and up with detached mode
cmds:
- task: down
- task: up-rebuild