57 lines
1.4 KiB
Makefile
57 lines
1.4 KiB
Makefile
WEB_DIR := web
|
|
SDK_DIR := sdk
|
|
ARCH ?= $(shell go env GOARCH)
|
|
GOOS ?= $(shell go env GOOS)
|
|
CONFIG_DIR ?= configs
|
|
CONFIG_FILE ?=
|
|
ENV_FILE ?= config.yml
|
|
BUILD_DIR ?= bin
|
|
|
|
.PHONY: web-install web-build sdk-install sdk-build build run test vet check seed-pet-doctor docker-config docker-up docker-down docker-logs
|
|
|
|
web-install:
|
|
cd $(WEB_DIR) && npm install
|
|
|
|
web-build:
|
|
cd $(WEB_DIR) && npm run build
|
|
|
|
sdk-install:
|
|
cd $(SDK_DIR) && npm install
|
|
|
|
sdk-build:
|
|
cd $(SDK_DIR) && npm run build
|
|
|
|
build: web-build sdk-build
|
|
@test -f $(CONFIG_DIR)/config.yml || (echo "missing base config: $(CONFIG_DIR)/config.yml"; exit 1)
|
|
@test -f $(CONFIG_DIR)/$(ENV_FILE) || (echo "missing environment file: $(CONFIG_DIR)/$(ENV_FILE)"; exit 1)
|
|
mkdir -p $(BUILD_DIR)/configs
|
|
cp $(CONFIG_DIR)/config.yml $(BUILD_DIR)/configs/config.yml
|
|
@if [ "$(ENV_FILE)" != "config.yml" ]; then cp $(CONFIG_DIR)/$(ENV_FILE) $(BUILD_DIR)/configs/$(ENV_FILE); fi
|
|
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -o $(BUILD_DIR)/main .
|
|
|
|
run: build
|
|
./$(BUILD_DIR)/main -config-dir $(if $(CONFIG_FILE),$(CONFIG_DIR),$(BUILD_DIR)/configs) $(if $(CONFIG_FILE),-config-file $(CONFIG_FILE),)
|
|
|
|
test:
|
|
go test ./...
|
|
|
|
vet:
|
|
go vet ./...
|
|
|
|
check: test vet
|
|
|
|
seed-pet-doctor:
|
|
go run ./scripts/seed-pet-doctor
|
|
|
|
docker-config:
|
|
docker compose config --quiet
|
|
|
|
docker-up:
|
|
docker compose up --build -d
|
|
|
|
docker-down:
|
|
docker compose down
|
|
|
|
docker-logs:
|
|
docker compose logs -f app nginx
|