移除docker.yml中冗余的go mod tidy和build-linux步骤,这些步骤已在其他流程中处理 将docker compose命令改为docker-compose以兼容旧版本
73 lines
2.5 KiB
Makefile
73 lines
2.5 KiB
Makefile
# Custom configuration | 独立配置
|
||
# Service name | 项目名称
|
||
SERVICE=ppanel
|
||
# Service name in specific style | 项目经过style格式化的名称
|
||
SERVICE_STYLE=ppanel
|
||
|
||
# Service name in lowercase | 项目名称全小写格式
|
||
SERVICE_LOWER=ppanel
|
||
# Service name in snake format | 项目名称下划线格式
|
||
SERVICE_SNAKE=ppanel
|
||
# Service name in snake format | 项目名称短杠格式
|
||
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
|
||
|
||
# Whether to use i18n | 是否启用 i18n
|
||
PROJECT_I18N=true
|
||
|
||
# The suffix after build or compile | 构建后缀
|
||
PROJECT_BUILD_SUFFIX=api
|
||
|
||
|
||
# The arch of the build | 构建的架构
|
||
GOARCH=amd64
|
||
|
||
# The repository of docker | Docker 仓库地址
|
||
DOCKER_REPO=docker.i.on ticcheck
|
||
|
||
# ---- 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 镜像
|
||
docker build -f Dockerfile -t ${API_IMAGE_NAME}:${VERSION} .
|
||
@echo "Build docker successfully"
|
||
|
||
.PHONY: publish-docker
|
||
publish-docker: # Publish docker image | 发布 docker 镜像
|
||
docker tag ${API_IMAGE_NAME}:${VERSION} ${API_IMAGE_NAME}:latest
|
||
docker push ${API_IMAGE_NAME}:latest
|
||
@echo "Publish docker successfully"
|
||
|
||
.PHONY: docker-run
|
||
docker-run: # Publish docker image | 发布 docker 镜像
|
||
docker rm -f ${API_CONTAINER_NAME}
|
||
docker-compose -p ${DOCKER_PROJECT_NAME} -f ${DOCKER_COMPOSE_FILE} up -d
|
||
@echo "docker run successfully"
|
||
|
||
|
||
.PHONY: build-linux
|
||
build-linux: # Build project for Linux | 构建Linux下的可执行文件
|
||
GOOS=linux GOARCH=$(GOARCH) $(GOBUILD) -o /app/ppanel $(SERVICE_STYLE).go
|
||
@echo "Build project for Linux successfully"
|
||
|
||
.PHONY: help
|
||
help: # Show help | 显示帮助
|
||
@grep kfile | sort | while read-r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done
|