68 lines
1.9 KiB
Makefile
68 lines
1.9 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
|
|
DIST_DIR ?= dist
|
|
|
|
.PHONY: web-install web-build sdk-install sdk-build build package-linux-amd64-prod 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 .
|
|
|
|
package-linux-amd64-prod: GOOS := linux
|
|
package-linux-amd64-prod: ARCH := amd64
|
|
package-linux-amd64-prod: ENV_FILE := config.prod.yml
|
|
package-linux-amd64-prod: BUILD_DIR := bin/linux-amd64-prod
|
|
package-linux-amd64-prod: PACKAGE_FILE := $(DIST_DIR)/iqudo-top1-linux-amd64-prod.tar.gz
|
|
package-linux-amd64-prod: build
|
|
mkdir -p $(DIST_DIR)
|
|
tar -czf $(PACKAGE_FILE) -C $(BUILD_DIR) main configs
|
|
@echo "created $(PACKAGE_FILE)"
|
|
|
|
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
|