This commit is contained in:
2024-07-19 17:04:42 +02:00
commit 5e0d0ec69f
71 changed files with 3316 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
# Set an output prefix, which is the local directory if not specified
PREFIX?=$(shell pwd)
.DEFAULT_GOAL := build
DOCKER_IMAGE_NAME := mangezmieux-backend
# Setup name variables for the package/tool
NAME := mangezmieux-backend
BIN_NAME := mangezmieux-backend
PKG := github.com/kratisto/mangezmieux-backend
# GO env vars
ifeq ($(GOPATH),)
GOPATH:=~/go
endif
GO=$(firstword $(subst :, ,$(GOPATH)))
.PHONY: ensure-vendor
ensure-vendor: ## Get all vendor dependencies
@echo "+ $@"
dep ensure
.PHONY: update-vendor
update-vendor: ## Get all vendor dependencies
@echo "+ $@"
dep ensure -update
.PHONY: clean
clean: local-clean ## Clean your generated files
@echo "+ $@"
docker image rm mangezmieux:snapshot || true
.PHONY: local-build
local-build: local-clean local-format ## Build locally the binary
@echo "+ $@"
go build -o $(GO)/bin/$(BIN_NAME) .
.PHONY: local-clean
local-clean: ## Cleanup locally any build binaries or packages
@echo "+ $@"
@$(RM) $(BIN_NAME)
.PHONY: local-format
local-format: ## format locally all files
@echo "+ $@"
gofmt -s -l -w .
.PHONY: build
build: sources-image ## Build the docker image with application binary
@echo "+ $@"
docker build --no-cache \
-f containers/Dockerfile \
--build-arg SOURCES_IMAGE=mangezmieux-sources:snapshot \
-t mangezmieux:snapshot .
GIT_CREDENTIALS?=$(shell cat ~/.git-credentials 2> /dev/null)
.PHONY: sources-image
sources-image: ## Generate a Docker image with only the sources
@echo "+ $@"
docker build -t mangezmieux-sources:snapshot -f containers/Dockerfile.sources .
.PHONY: liquibase
liquibase: ## Run the dependencies of the server (launch the containers/docker-compose.local.yml)
@echo "+ $@"
@docker run --network host --rm -v ./liquibase/changelogs:/liquibase/changelog liquibase/liquibase --defaults-file=/liquibase/changelog/liquibase.properties --changelog-file=changelog-master.xml --classpath=changelog update
.PHONY: local-run-golang
local-run-golang: ## Build the server and run it
@echo "+ $@"
BUILD_GOLANG_CMD=local-build \
LAUNCH_GOLANG_CMD="$(GO)/bin/$(BIN_NAME)" \
$(MAKE) local-launch-golang
.PHONY: local-launch-golang
local-launch-golang: ## Build the server and run it
@echo "+ $@"
PID=`ps -ax | egrep "\b$(BIN_NAME)"| cut -d " " -f 1`; \
kill $$PID || true
$(MAKE) $(BUILD_GOLANG_CMD)
DB_PORT=`` $(LAUNCH_GOLANG_CMD) serve --loglevel debug --logformat text --postgreshost localhost:$$DB_PORT
.PHONY: local-run
local-run: local-run-golang ## Run the server with its dependencies