SimpleCloudNotifier/server/Makefile

74 lines
1.9 KiB
Makefile
Raw Normal View History

2022-11-13 19:17:07 +01:00
DOCKER_REPO=registry.blackforestbytes.com
DOCKER_NAME=scn_server
PORT=9090
NAMESPACE=$(shell git rev-parse --abbrev-ref HEAD)
HASH=$(shell git rev-parse HEAD)
2022-11-21 22:52:44 +01:00
build: swagger fmt
2022-11-13 19:17:07 +01:00
rm -f ./_build/scn_backend
CGO_ENABLED=1 go build -v -o _build/scn_backend -tags timetzdata ./cmd/scnserver
2022-11-13 19:17:07 +01:00
run: build
mkdir -p .run-data
_build/scn_backend
2022-11-21 22:52:44 +01:00
docker: build
2022-11-13 19:17:07 +01:00
[ ! -f "DOCKER_GIT_INFO" ] || rm DOCKER_GIT_INFO
git rev-parse --abbrev-ref HEAD >> DOCKER_GIT_INFO
git rev-parse HEAD >> DOCKER_GIT_INFO
git log -1 --format=%cd --date=iso >> DOCKER_GIT_INFO
git config --get remote.origin.url >> DOCKER_GIT_INFO
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
.PHONY: swagger
swagger:
2022-11-13 19:17:07 +01:00
which swag || go install github.com/swaggo/swag/cmd/swag@latest
swag init -generalInfo api/router.go --output ./swagger/ --outputTypes "json,yaml"
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
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
.PHONY: test
test:
go test ./test/...