diff --git a/makefile b/makefile index cbc4ea6..fdb2c68 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ FRONTEND_DIR = ./web BACKEND_DIR = . -.PHONY: all build-frontend start-backend +.PHONY: all build-frontend start-backend docker-build docker-push all: build-frontend start-backend @@ -12,3 +12,17 @@ build-frontend: 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-build + @echo "Pushing Docker image: $(DOCKER_TAG)" + docker push $(DOCKER_TAG)