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
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-AUTH2_go 1>/dev/null 2>&1 || podman volume create jo-AUTH2_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-AUTH2_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 :
- ./**/*.proto
cmds :
- task : builder
vars :
CLI_ARGS : /scripts/protoc_gen.sh
build:authsql :
deps :
- protoc
sources :
- ./go.sum
- ./*.go
- ./cmd/microauth2sqld/**/*.go
- ./internal/**/*.go
- ./plugins/**/*.go
- ./shared/**/*.go
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}}/auth2-sql:latest
-f ./docker/microauth2sqld/Dockerfile
.
vars :
DATE :
sh : date -u -Iseconds
VOLUME_PATH :
sh : podman volume inspect jo-AUTH2_go --format "{{"{{"}}.Mountpoint{{"}}"}}"
BUILD_MOUNT_FOLDER_INT :
sh : realpath {{.BUILD_MOUNT_FOLDER}}
podman :
desc : Generate docker container for jo-micro/auth-sql tagged as {{.DOCKER_ORG_JO_MICRO}}/auth2-sql:latest
cmds :
- task : build:authsql
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
fmt :
desc : Run "go fmt ./..." in a container
cmds :
- task : builder
vars :
CLI_ARGS : go fmt ./...
keys :
desc : Generate JWT keys (use --auth2_generate_format=RSA4096 for RSA)
cmds :
- podman run {{.DOCKER_ORG_JO_MICRO}}/auth2-sql:latest microauth2sqld --auth2_generate_keys
rm :
desc : Remove all persistent data
cmds :
- podman volume rm jo-AUTH2_go || exit 0
- podman image rm {{.DOCKER_ORG_JO_MICRO}}/auth2-sql:latest || exit 0
- rm -rf $PWD/.task
up :
desc : Run all containers
cmds :
- podman-compose up -d --remove-orphans
ps :
desc : Show running containers
cmds :
- podman-compose ps
down :
desc : Stopp all containers
cmds :
- podman-compose down