PROJECT:=go-admin .PHONY: build version version?=latest build: CGO_ENABLED=0 go build -o bin/observe -ldflags="-w -s" -a -installsuffix . linux-build: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/observe -ldflags="-w -s" -a -installsuffix . linux-event-build: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/observe-event -ldflags="-w -s" -a -installsuffix . # make build-linux build-linux: @docker build -t go-admin:latest . @echo "build successful" build-sqlite: go build -tags sqlite3 -ldflags="-w -s" -a -installsuffix -o bin/observe . run: bin/observe server -c config/settings.yml run-nodeport: bin/observe server -c config/settings.nodeport.yml # make run docker-run: # delete go-admin-api container # @if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker rm -f go-admin; fi # 启动方法一 run go-admin-api container docker-compose 启动方式 # 进入到项目根目录 执行 make run 命令 # @docker-compose up -d # 启动方式二 docker run 这里注意-v挂载的宿主机的地址改为部署时的实际决对路径 #@docker run --name=go-admin -p 8000:8000 -v /home/code/go/src/go-admin/go-admin/config:/go-admin-api/config -v /home/code/go/src/go-admin/go-admin-api/static:/go-admin/static -v /home/code/go/src/go-admin/go-admin/temp:/go-admin-api/temp -d --restart=always go-admin:latest @echo "go-admin service is running..." # delete Tag= 的镜像 @docker image prune -f @docker ps -a | grep "go-admin" stop: # delete go-admin-api container @if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker-compose down; fi #@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker rm -f go-admin; fi #@echo "go-admin stop success" DOCKER_IMAGE_NAME=observe-server DOCKER_REMOTE_IMAGE_NAME=reg.cestong.com.cn/cecf/${DOCKER_IMAGE_NAME}:${version} create-version: git pull git rev-parse --short HEAD > version go mod tidy docker-build: docker build . -f Dockerfile -t ${DOCKER_IMAGE_NAME} docker-push: docker tag ${DOCKER_IMAGE_NAME} ${DOCKER_REMOTE_IMAGE_NAME} docker push ${DOCKER_REMOTE_IMAGE_NAME} docker: create-version linux-build docker-build docker-push deploy: create-version docker-build docker-push kubectl rollout restart deployment ob-server EVENT_IMAGE_NAME=observe-event EVENT_REMOTE_IMAGE_NAME=reg.cestong.com.cn/cecf/${EVENT_IMAGE_NAME} event-build: docker build . -f Dockerfile -t ${EVENT_IMAGE_NAME} event-push: docker tag ${EVENT_IMAGE_NAME} ${EVENT_REMOTE_IMAGE_NAME} docker push ${EVENT_REMOTE_IMAGE_NAME} event: create-version linux-event-build event-build event-push #.PHONY: test #test: # go test -v ./... -cover #.PHONY: docker #docker: # docker build . -t go-admin:latest # make deploy # deploy: # #@git checkout master # #@git pull origin master # make build-linux # make run