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)
|
|
|
|
|
2022-12-21 18:14:13 +01:00
|
|
|
.PHONY: test swagger
|
|
|
|
|
2022-11-21 22:52:44 +01:00
|
|
|
build: swagger 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:
|
|
|
|
# go install github.com/mitranim/gow@latest
|
|
|
|
gow run blackforestbytes.com/portfoliomanager2/cmd/server
|
|
|
|
|
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
|
|
|
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
|
|
|
|
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:
|
|
|
|
go test ./test/...
|
|
|
|
|
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
|
|
|
|