refactor: 更新Dockerfile和Makefile配置

统一服务名称为Ppanel并更新相关变量命名
优化Makefile结构,移除无用swagger相关命令
添加构建时间变量并改进构建命令
This commit is contained in:
shanshanzhong 2025-07-23 07:36:26 -07:00
parent 6c9d5fb39e
commit df7fcddb40
2 changed files with 21 additions and 48 deletions

View File

@ -43,4 +43,4 @@ EXPOSE 8080
# Specify entry point
ENTRYPOINT ["/app/ppanel"]
CMD ["run", "--config", "etc/ppanel.yaml"]
CMD ["ppanel_api", "--config", "etc/ppanel.yaml"]

View File

@ -1,10 +1,11 @@
# Custom configuration | 独立配置
# Service name | 项目名称
SERVICE=Mininppp
SERVICE=Ppanel
# Service name in specific style | 项目经过style格式化的名称
SERVICE_STYLEminia=mpp
SERVICE_STYLE=ppanel
# Service name in lowercase | 项目名称全小写格式
SERVICE_LOWEminiaR=app
SERVICE_LOWER=ppanel
# Service name in snake format | 项目名称下划线格式
SERVICE_SNAKE=ppanel
# Service name in snake format | 项目名称短杠格式
@ -12,6 +13,8 @@ SERVICE_DASH=ppanel
# The project version, if you don't use git, you should set it manually | 项目版本如果不使用git请手动设置
VERSION=$(shell git describe --tags --always)
# Build time | 构建时间
BUILDTIME=$(shell date '+%Y-%m-%d %H:%M:%S')
# The project file name style | 项目文件命名风格
PROJECT_STYLE=go_zero
@ -20,11 +23,7 @@ PROJECT_STYLE=go_zero
PROJECT_I18N=true
# The suffix after build or compile | 构建后缀
PROJECT_BUILD_SUapiFFIX=api
# Swagger type, support yml,json | Swagger 文件类型支持yml,json
SWAGGER_TYP
E=json
PROJECT_BUILD_SUFFIX=api
# The arch of the build | 构建的架构
@ -33,11 +32,17 @@ GOARCH=amd64
# The repository of docker | Docker 仓库地址
DOCKER_REPO=docker.i.on ticcheck
.PHONY: tools
tools: # Install the necessary tools | 安装必要的工具
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest;
$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest
# ---- You may not need to modify the codes below | 下面的代码大概率不需要更改 ----
GO ?= go
GOFMT ?= gofmt "-s"
GOFILES := $(shell find . -name "*.go")
LDFLAGS := -s -w
# Build command with version injection | 带版本信息注入的构建命令
GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/perfect-panel/server/pkg/constant.Version=$(VERSION)" \
-X "github.com/perfect-panel/server/pkg/constant.BuildTime=$(BUILDTIME)" \
-w -s -buildid='
.PHONY: docker
docker: # Build the docker image | 构建 docker 镜像
@ -57,42 +62,10 @@ docker-run: # Publish docker image | 发布 docker 镜像
docker compose -p ${DOCKER_PROJECT_NAME} -f ${DOCKER_COMPOSE_FILE} up -d
@echo "docker run successfully"
.PHONY: swagger-docker
swagger-docker: # Run the swagger Docker | 运行接口文档服务
@echo "run swagger-ui container..."
docker rm -f ${PROJECT_NAME}-${SERVICE_NAME}-apidoc
docker compose -p ${DOC_DOCKER_PROJECT_NAME} -f ${APIDOC_DOCKER_COMPOSE_FILE} up -d
@echo "run swagger-ui container successfully"
.PHONY: gen-swagger
gen-swagger: # Generate swagger file | 生成 swagger 文件
swagger generate spec --output=./$(SERVICE_STYLE).$(SWAGGER_TYPE) --scan-models
@echo "Generate swagger successfully"
.PHONY: serve-swagger
serve-swagger: # Run the swagger server | 运行 swagger 服务
lsof -i:36666 | awk 'NR!=1 {print $2}' | xargs killall -9 || true
swagger serve -F=swagger --port 36666 $(SERVICE_STYLE).$(SWAGGER_TYPE)
@echo "Serve swagger-ui successfully"
.PHONY: gen-api
gen-api: # Generate API files | 生成 API 的代码
goctls api go --api ./desc/all.api --dir ./ --trans_err=true --style=$(PROJECT_STYLE)
swagger generate spec --output=./$(SERVICE_STYLE).$(SWAGGER_TYPE) --scan-models
@echo "Generate API codes successfully"
.PHONY: build-win
build-win: # Build project for Windows | 构建Windows下的可执行文件
env CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX).exe $(SERVICE_STYLE).go
@echo "Build project for Windows successfully"
.PHONY: build-mac
build-mac: # Build project for MacOS | 构建MacOS下的可执行文件
env CGO_ENABLED=0 GOOS=darwin GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go
@echo "Build project for MacOS successfully"
.PHONY: build#oject for Linux | 构建Linx下的可执行文件
env CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go
.PHONY: build-linux
build-linux: # Build project for Linux | 构建Linux下的可执行文件
GOOS=linux GOARCH=$(GOARCH) $(GOBUILD) -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go
@echo "Build project for Linux successfully"
.PHONY: help