FRONTEND_DIR = ./web
BACKEND_DIR = .

.PHONY: all build-frontend start-backend docker-build docker-push

all: build-frontend start-backend

build-frontend:
	@echo "Building frontend..."
	@cd $(FRONTEND_DIR) && bun install && DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build

start-backend:
	@echo "Starting backend dev server..."
	@cd $(BACKEND_DIR) && go run main.go &

# Docker 配置
DOCKER_REGISTRY := registry.cn-hangzhou.aliyuncs.com/fengsilin/new-api
BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//-/g')
BUILD_TIME := $(shell date +%Y%m%d%H%M)
DOCKER_TAG := $(DOCKER_REGISTRY):$(BUILD_TIME)-$(BRANCH_NAME)

docker-build:
	@echo "Building Docker image with tag: $(DOCKER_TAG)"
	docker build -t $(DOCKER_TAG) .
	#docker push $(DOCKER_TAG)

docker-push: docker-build
	@echo "Pushing Docker image: $(DOCKER_TAG)"
	docker push $(DOCKER_TAG)
