47 lines
866 B
Makefile
47 lines
866 B
Makefile
.PHONY: all test clean build
|
|
|
|
OUT=./tmp/main
|
|
GOOS=linux
|
|
GOARCH=amd64
|
|
DOCKER_IMG=
|
|
DOCKER_REG=
|
|
all: tidy build run
|
|
|
|
# Ignore
|
|
tidy:
|
|
@echo -ne "Formating Code \r"
|
|
@go fmt ./...
|
|
@rm $(OUT)
|
|
@go mod tidy -v
|
|
@go mod vendor
|
|
|
|
test:
|
|
@echo -ne "Running Tests \r"
|
|
@go test ./...
|
|
|
|
build-proto:
|
|
@echo -ne "Generating Proto Stubs\r"
|
|
@buf generate
|
|
|
|
build-docker:
|
|
@echo -ne "Generating Docker Image\r"
|
|
@docker build . --no-cache -t $(DOCKER_IMG)
|
|
@docker tag $(DOCKER_IMG) $(DOCKER_REG)/$(DOCKER_IMG)
|
|
|
|
build-bin:
|
|
@echo -ne "Building Binary \r"
|
|
@if [[ "$OSTYPE" == "linux-gnu" ]]; then\
|
|
go build -o $(OUT) .;\
|
|
else\
|
|
env GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(OUT) .;\
|
|
fi
|
|
@if ! [ -f "$(OUT)" ]; then\
|
|
echo -ne "could'nt build the binary file. exit the process...";\
|
|
exit 1;\
|
|
fi
|
|
|
|
run:
|
|
@./$(OUT) serve --conf ./cfg.toml
|
|
|
|
build: build-proto build-bin
|