version : '3'
dotenv : [ ".env" ]
vars :
GIT_TAG :
sh : git tag --points-at HEAD
GIT_COMMIT :
sh : git rev-parse --short HEAD
GIT_DIRTY :
sh : git status -s
VERSION :
sh : if test "{{.GIT_DIRTY}}" != ""; then echo "{{.GIT_COMMIT}}-dirty"; elif test "{{.GIT_TAG}}" != ""; then echo "{{.GIT_TAG}}"; else echo "{{.GIT_COMMIT}}"; fi
PWD :
sh : echo $PWD
tasks :
default :
cmds :
- task : version
- task : volume
- task : podman
version :
desc : Print the version optained from git
cmds :
- echo "{{.VERSION}}"
volume :
run : "once"
cmds :
- podman volume inspect jo_micro-router_go 1>/dev/null 2>&1 || podman volume create jo_micro-router_go
builder :
desc : Run something in the builder container for example "task builder -- go get -u ./..."
cmds :
- podman run --rm
-v "{{.BUILD_MOUNT_FOLDER_INT}}:{{.BUILD_MOUNT_FOLDER_INT}}"
-v "{{.PWD}}:/code"
-v "{{.VOLUME_PATH}}:/go:rw"
{{.DOCKER_ORG_JO_MICRO}}/builder:latest {{.CLI_ARGS}}
vars :
VOLUME_PATH :
sh : podman volume inspect jo_micro-router_go --format "{{"{{"}}.Mountpoint{{"}}"}}"
BUILD_MOUNT_FOLDER_INT :
sh : realpath {{.BUILD_MOUNT_FOLDER}}
preconditions :
- test -n "{{.CLI_ARGS}}"
protoc :
run : "once"
desc : Generate protobruf go files
sources :
- ./internal/proto/**/*.proto
cmds :
- task : builder
vars :
CLI_ARGS : /scripts/protoc_gen.sh
build:podman :
sources :
- ./go.sum
- ./go.work.sum
- ./cmd/microrouterd/**/*.go
- ./internal/**/*.go
- /*.go
deps :
- protoc
cmds :
- podman build
-v "{{.BUILD_MOUNT_FOLDER_INT}}:{{.BUILD_MOUNT_FOLDER_INT}}"
-v "{{.VOLUME_PATH}}:/go:rw"
--build-arg CACHEBUST={{.DATE}}
--build-arg VERSION={{.VERSION}}
--build-arg=DOCKER_IO={{.DOCKER_IO}}
--build-arg=DOCKER_ORG_JO_MICRO={{.DOCKER_ORG_JO_MICRO}}
-t {{.DOCKER_ORG_JO_MICRO}}/router:latest
-f ./docker/router/Dockerfile
.
vars :
DATE :
sh : date -u -Iseconds
VOLUME_PATH :
sh : podman volume inspect jo_micro-router_go --format "{{"{{"}}.Mountpoint{{"}}"}}"
BUILD_MOUNT_FOLDER_INT :
sh : realpath {{.BUILD_MOUNT_FOLDER}}
podman :
desc : Generate docker container for jo-micro/router tagged as {{.DOCKER_ORG_JO_MICRO}}/router:latest
cmds :
- task : build:podman
tidy :
desc : Run "go mod tidy" in a container
cmds :
- task : builder
vars :
CLI_ARGS : go mod tidy
update :
desc : Run "go get -u ./..." in a container
cmds :
- task : builder
vars :
CLI_ARGS : /scripts/upgrade_deps.sh
rm :
desc : Remove all persistent data
cmds :
- podman image rm {{.DOCKER_ORG_JO_MICRO}}/router:latest || exit 0
- podman volume rm jo_micro-router_go || exit 0
- rm -rf $PWD/.task