2022-11-13 19:17:07 +01:00
|
|
|
DOCKER_REPO=registry.blackforestbytes.com
|
2022-12-16 14:57:17 +01:00
|
|
|
DOCKER_NAME=mikescher/simplecloudnotifier
|
2022-11-13 19:17:07 +01:00
|
|
|
PORT=9090
|
|
|
|
|
|
|
|
NAMESPACE=$(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
HASH=$(shell git rev-parse HEAD)
|
|
|
|
|
2023-05-28 16:03:14 +02:00
|
|
|
.PHONY: test swagger pygmentize docker
|
2022-12-21 18:14:13 +01:00
|
|
|
|
2023-05-27 17:42:06 +02:00
|
|
|
build: swagger pygmentize fmt
|
2022-12-16 01:07:48 +01:00
|
|
|
mkdir -p _build
|
2022-11-13 19:17:07 +01:00
|
|
|
rm -f ./_build/scn_backend
|
2023-04-21 21:45:16 +02:00
|
|
|
go generate ./...
|
2022-12-07 22:11:44 +01:00
|
|
|
CGO_ENABLED=1 go build -v -o _build/scn_backend -tags "timetzdata sqlite_fts5 sqlite_foreign_keys" ./cmd/scnserver
|
2022-11-13 19:17:07 +01:00
|
|
|
|
|
|
|
run: build
|
|
|
|
mkdir -p .run-data
|
|
|
|
_build/scn_backend
|
|
|
|
|
2023-04-21 21:45:16 +02:00
|
|
|
gow:
|
2023-05-27 17:42:06 +02:00
|
|
|
which gow || go install github.com/mitranim/gow@latest
|
|
|
|
gow -e "go,mod,html,css,json,yaml,js" run -tags "timetzdata sqlite_fts5 sqlite_foreign_keys" blackforestbytes.com/simplecloudnotifier/cmd/scnserver
|
2023-04-21 21:45:16 +02:00
|
|
|
|
2023-06-06 18:52:03 +02:00
|
|
|
dgi:
|
2022-11-13 19:17:07 +01:00
|
|
|
[ ! -f "DOCKER_GIT_INFO" ] || rm DOCKER_GIT_INFO
|
2023-06-06 18:52:03 +02:00
|
|
|
echo -n "VCSTYPE=" >> DOCKER_GIT_INFO ; echo "git" >> DOCKER_GIT_INFO
|
|
|
|
echo -n "BRANCH=" >> DOCKER_GIT_INFO ; git rev-parse --abbrev-ref HEAD >> DOCKER_GIT_INFO
|
|
|
|
echo -n "HASH=" >> DOCKER_GIT_INFO ; git rev-parse HEAD >> DOCKER_GIT_INFO
|
|
|
|
echo -n "COMMITTIME=" >> DOCKER_GIT_INFO ; git log -1 --format=%cd --date=iso >> DOCKER_GIT_INFO
|
|
|
|
echo -n "REMOTE=" >> DOCKER_GIT_INFO ; git config --get remote.origin.url >> DOCKER_GIT_INFO
|
|
|
|
|
|
|
|
build-docker: dgi
|
2022-11-13 19:17:07 +01:00
|
|
|
docker build \
|
|
|
|
-t "$(DOCKER_NAME):$(HASH)" \
|
|
|
|
-t "$(DOCKER_NAME):$(NAMESPACE)-latest" \
|
|
|
|
-t "$(DOCKER_NAME):latest" \
|
|
|
|
-t "$(DOCKER_REPO)/$(DOCKER_NAME):$(HASH)" \
|
|
|
|
-t "$(DOCKER_REPO)/$(DOCKER_NAME):$(NAMESPACE)-latest" \
|
|
|
|
-t "$(DOCKER_REPO)/$(DOCKER_NAME):latest" \
|
|
|
|
.
|
|
|
|
|
2022-11-19 12:47:23 +01:00
|
|
|
swagger:
|
2023-04-25 20:08:30 +02:00
|
|
|
which swag || go install github.com/swaggo/swag/cmd/swag@v1.8.12
|
2022-11-30 17:58:04 +01:00
|
|
|
swag init -generalInfo api/router.go --propertyStrategy snakecase --output ./swagger/ --outputTypes "json,yaml"
|
2022-11-13 19:17:07 +01:00
|
|
|
|
2023-05-27 17:42:06 +02:00
|
|
|
pygmentize: website/scn_send.html
|
|
|
|
|
|
|
|
website/scn_send.html: website/scn_send.sh.txt
|
|
|
|
_pygments/pygmentizew -l bash -f html "$(shell pwd)/website/scn_send.sh.txt" > "$(shell pwd)/website/scn_send.html"
|
|
|
|
_pygments/pygmentizew -S monokai -f html > "$(shell pwd)/website/css/pygmnetize-dark.css"
|
|
|
|
_pygments/pygmentizew -S borland -f html > "$(shell pwd)/website/css/pygmnetize-light.css"
|
|
|
|
|
2022-11-21 22:52:44 +01:00
|
|
|
run-docker-local: docker
|
2022-11-13 19:17:07 +01:00
|
|
|
mkdir -p .run-data
|
|
|
|
docker run --rm \
|
|
|
|
--init \
|
2022-11-20 03:41:38 +01:00
|
|
|
--env "CONF_NS=local-docker" \
|
2022-11-13 19:17:07 +01:00
|
|
|
--volume "$(shell pwd)/.run-data/docker-local:/data" \
|
2022-11-20 03:41:38 +01:00
|
|
|
--publish "8080:80" \
|
2022-11-13 19:17:07 +01:00
|
|
|
$(DOCKER_NAME):latest
|
|
|
|
|
2022-11-21 22:52:44 +01:00
|
|
|
inspect-docker: docker
|
2022-11-13 19:17:07 +01:00
|
|
|
mkdir -p .run-data
|
|
|
|
docker run -ti \
|
|
|
|
--rm \
|
|
|
|
--volume "$(shell pwd)/.run-data/docker-inspect:/data" \
|
|
|
|
$(DOCKER_NAME):latest \
|
|
|
|
bash
|
|
|
|
|
2022-11-21 22:52:44 +01:00
|
|
|
push-docker: docker
|
2022-11-13 19:17:07 +01:00
|
|
|
docker image push "$(DOCKER_REPO)/$(DOCKER_NAME):$(HASH)"
|
|
|
|
docker image push "$(DOCKER_REPO)/$(DOCKER_NAME):$(NAMESPACE)-latest"
|
|
|
|
docker image push "$(DOCKER_REPO)/$(DOCKER_NAME):latest"
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf _build/*
|
|
|
|
rm -rf .run-data/*
|
|
|
|
git clean -fdx
|
|
|
|
go clean
|
2022-11-24 12:53:27 +01:00
|
|
|
go clean -testcache
|
2022-11-13 19:17:07 +01:00
|
|
|
|
|
|
|
fmt:
|
|
|
|
go fmt ./...
|
|
|
|
swag fmt
|
2022-11-24 12:53:27 +01:00
|
|
|
|
|
|
|
test:
|
2023-05-27 15:39:07 +02:00
|
|
|
which gotestsum || go install gotest.tools/gotestsum@latest
|
|
|
|
gotestsum --format "testname" -- -tags="timetzdata sqlite_fts5 sqlite_foreign_keys" "./test"
|
2022-11-24 12:53:27 +01:00
|
|
|
|
2023-01-15 06:30:30 +01:00
|
|
|
migrate:
|
|
|
|
CGO_ENABLED=1 go build -v -o _build/scn_migrate -tags "timetzdata sqlite_fts5 sqlite_foreign_keys" ./cmd/migrate
|
|
|
|
./_build/scn_migrate
|
2022-11-24 12:53:27 +01:00
|
|
|
|