SimpleCloudNotifier/scnserver/Makefile

115 lines
3.8 KiB
Makefile
Raw Normal View History

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)
TAGS="timetzdata sqlite_fts5 sqlite_foreign_keys"
2023-06-17 23:40:46 +02:00
.PHONY: test swagger pygmentize docker migrate dgi pygmentize lint docker
2023-10-17 15:53:39 +02:00
SWAGGO_VERSION=v1.8.12
SWAGGO=github.com/swaggo/swag/cmd/swag@$(SWAGGO_VERSION)
2023-10-26 13:14:11 +02:00
build: ids enums 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
CGO_ENABLED=1 go build -v -o _build/scn_backend -tags $(TAGS) ./cmd/scnserver
2022-11-13 19:17:07 +01:00
2023-10-26 13:14:11 +02:00
enums:
go generate models/enums.go
ids:
go generate models/ids.go
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:
which gow || go install github.com/mitranim/gow@latest
gow -e "go,mod,html,css,json,yaml,js" run -tags $(TAGS) 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
2023-06-17 23:40:46 +02:00
docker: dgi
2023-10-17 15:53:39 +02:00
cp ../scn_send.sh .
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" \
.
2023-10-17 15:53:39 +02:00
[ -f "scn_send.sh" ] && rm scn_send.sh
swagger-setup:
mkdir -p ".swaggobin"
[ -f ".swaggobin/swag_$(SWAGGO_VERSION)" ] || { GOBIN=/tmp/_swaggo go install $(SWAGGO); cp "/tmp/_swaggo/swag" ".swaggobin/swag_$(SWAGGO_VERSION)"; rm -rf "/tmp/_swaggo"; }
2022-11-13 19:17:07 +01:00
2023-10-17 15:53:39 +02:00
swagger: swagger-setup
".swaggobin/swag_$(SWAGGO_VERSION)" init -generalInfo ./api/router.go --propertyStrategy camelcase --output ./swagger/ --outputTypes "json,yaml"
2022-11-13 19:17:07 +01:00
pygmentize: website/scn_send.html
2023-10-14 21:37:00 +02:00
website/scn_send.html: ../scn_send.sh
_pygments/pygmentizew -l bash -f html "$(shell pwd)/../scn_send.sh" > "$(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 \
--env "CONF_NS=local-docker" \
2022-11-13 19:17:07 +01:00
--volume "$(shell pwd)/.run-data/docker-local:/data" \
--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
2023-08-12 11:52:02 +02:00
push-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/*
2023-10-17 15:53:39 +02:00
rm -rf _pygments/env
2022-11-13 19:17:07 +01:00
git clean -fdx
2023-08-16 09:45:44 +02:00
! which go 2>&1 >> /dev/null || go clean
! which go 2>&1 >> /dev/null || go clean -testcache
2022-11-13 19:17:07 +01:00
2023-10-17 15:53:39 +02:00
fmt: swagger-setup
2022-11-13 19:17:07 +01:00
go fmt ./...
2023-10-17 15:53:39 +02:00
".swaggobin/swag_$(SWAGGO_VERSION)" 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 $(TAGS) "./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 $(TAGS) ./cmd/migrate
2023-01-15 06:30:30 +01:00
./_build/scn_migrate
2022-11-24 12:53:27 +01:00
2023-06-14 15:03:37 +02:00
lint:
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.2
golangci-lint run ./...