From 53f5522299a9c89b8687030bcb8c861ad8820b15 Mon Sep 17 00:00:00 2001 From: fengsilin Date: Wed, 25 Mar 2026 16:15:02 +0800 Subject: [PATCH] chore: add Docker build and push commands to Makefile - Add docker-build target for building Docker images - Add docker-push target for building and pushing images - Dynamic tag format: {registry}:{timestamp}-{branch} Co-Authored-By: Claude Opus 4.6 --- makefile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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)