statping/Makefile

243 lines
12 KiB
Makefile
Raw Normal View History

2018-11-29 02:03:41 +00:00
VERSION=$(shell cat version.txt)
2018-12-04 10:13:08 +00:00
SIGN_KEY=B76D61FAA6DB759466E83D9964B9C6AAE2D55278
2018-12-04 04:17:29 +00:00
BINARY_NAME=statping
2019-12-29 21:52:19 +00:00
GOBUILD=go build -a
2020-03-03 16:19:55 +00:00
GOVERSION=1.14
2019-12-29 21:52:19 +00:00
XGO=xgo -go $(GOVERSION) --dest=build
2018-11-29 02:03:41 +00:00
BUILDVERSION=-ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=$(TRAVIS_COMMIT)"
2020-01-08 03:44:26 +00:00
TRVIS_SECRET=lRqWSt5BoekFK6+padJF+b77YkGdispPXEUKNuD7/Hxb7yJMoI8T/n8xZrTHtCZPdjtpy7wIlJCezNoYEZB3l2GnD6Y1QEZEXF7MIxP7hwsB/uSc5/lgdGW0ZLvTBfv6lwI/GjQIklPBW/4xcKJtj4s1YBP7xvqyIb/lDN7TiOqAKF4gqRVVfsxvlkm7j4TiPCXtz17hYQfU8kKBbd+vd3PuZgdWqs//5RwKk3Ld8QR8zoo9xXQVC5NthiyVbHznzczBsHy2cRZZoWxyi7eJM1HrDw8Jn/ivJONIHNv3RgFVn2rAoKu1X8F6FyuvPO0D2hWC62mdO/e0kt4X0mn9/6xlLSKwrHir67UgNVQe3tvlH0xNKh+yNZqR5x9t0V54vNks6Pgbhas5EfLHoWn5cF4kbJzqkXeHjt1msrsqpA3HKbmtwwjJr4Slotfiu22mAhqLSOV+xWV+IxrcNnrEq/Pa+JAzU12Uyxs8swaLJGPRAlWnJwzL9HK5aOpN0sGTuSEsTwj0WxeMMRx25YEq3+LZOgwOy3fvezmeDnKuBZa6MVCoMMpx1CRxMqAOlTGZXHjj+ZPmqDUUBpzAsFSzIdVRgcnDlLy7YRiz3tVWa1G5S07l/VcBN7ZgvCwOWZ0QgOH0MxkoDfhrfoMhNO6MBFDTRKCEl4TroPEhcInmXU8=
2018-12-19 19:07:05 +00:00
PUBLISH_BODY='{ "request": { "branch": "master", "message": "Homebrew update version v${VERSION}", "config": { "env": { "VERSION": "${VERSION}", "COMMIT": "$(TRAVIS_COMMIT)" } } } }'
2020-03-09 18:17:55 +00:00
TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master for Statping v${VERSION}", "config": { "os": [ "linux" ], "language": "go", "go": [ "${GOVERSION}" ], "go_import_path": "github.com/statping/statping", "install": true, "sudo": "required", "services": [ "docker" ], "env": { "VERSION": "${VERSION}", "secure": "${TRVIS_SECRET}" }, "matrix": { "allow_failures": [ { "go": "master" } ], "fast_finish": true }, "before_deploy": [ "git config --local user.name \"hunterlong\"", "git config --local user.email \"info@socialeck.com\"", "git tag v$(VERSION) --force"], "deploy": [ { "provider": "releases", "api_key": "$$TAG_TOKEN", "file_glob": true, "file": "build/*", "skip_cleanup": true, "on": {"branch": "master"} } ], "notifications": { "email": false }, "before_script": ["gem install sass"], "script": [ "travis_wait 30 docker pull crazymax/xgo:$(GOVERSION)", "make release" ], "after_success": [], "after_deploy": [ "make publish-homebrew" ] } } }'
TEST_DIR=$(GOPATH)/src/github.com/statping/statping
2019-12-29 21:52:19 +00:00
PATH:=/usr/local/bin:$(GOPATH)/bin:$(PATH)
2018-08-15 08:08:50 +00:00
2020-03-04 10:29:00 +00:00
all: clean yarn-install compile docker-base docker-vue build-all compress
2020-02-28 06:37:48 +00:00
up:
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml up -d --remove-orphans
make print_details
2020-02-27 10:04:27 +00:00
down:
2020-02-28 06:37:48 +00:00
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml down --volumes --remove-orphans
2020-03-09 15:15:15 +00:00
test: clean
go test -v -p=1 -ldflags="-X main.VERSION=dev" -coverprofile=coverage.out ./...
2020-02-28 07:56:17 +00:00
lite: clean
2020-02-29 15:00:08 +00:00
docker build -t hunterlong/statping:dev -f dev/Dockerfile.dev .
docker-compose -f dev/docker-compose.lite.yml down
docker-compose -f dev/docker-compose.lite.yml up --remove-orphans
2020-02-28 07:56:17 +00:00
2020-02-28 06:37:48 +00:00
reup: down clean compose-build-full up
2020-02-29 23:36:31 +00:00
yarn-serve:
cd frontend && yarn serve
2020-03-04 10:29:00 +00:00
yarn-install:
cd frontend && rm -rf node_modules && yarn
2020-02-29 23:36:31 +00:00
go-run:
go run ./cmd
2020-02-28 06:37:48 +00:00
start:
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml start
stop:
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml stop
2020-01-15 04:58:22 +00:00
2020-02-27 10:04:27 +00:00
logs:
docker logs statping --follow
2018-12-04 19:13:24 +00:00
2020-03-06 09:33:46 +00:00
db-up:
docker-compose -f dev/docker-compose.db.yml up -d --remove-orphans
db-down:
docker-compose -f dev/docker-compose.full.yml down --remove-orphans
2020-02-27 10:04:27 +00:00
console:
docker exec -t -i statping /bin/sh
2018-08-17 16:13:20 +00:00
2020-02-28 06:37:48 +00:00
compose-build-full: docker-base
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml build --parallel --build-arg VERSION=${VERSION}
2020-02-27 10:04:27 +00:00
docker-base:
2020-03-05 21:19:28 +00:00
docker build -t hunterlong/statping:base -f Dockerfile.base --no-cache --build-arg VERSION=${VERSION} .
2020-02-27 10:04:27 +00:00
docker-latest: docker-base
docker build -t hunterlong/statping:latest --build-arg VERSION=${VERSION} .
2018-10-08 21:15:01 +00:00
2020-02-27 10:04:27 +00:00
docker-vue:
docker build -t hunterlong/statping:vue --build-arg VERSION=${VERSION} .
2020-03-06 18:46:01 +00:00
push-base: docker-base
docker push hunterlong/statping:base
2020-03-05 21:19:28 +00:00
push-vue: clean docker-base docker-vue
2020-03-01 06:31:55 +00:00
docker push hunterlong/statping:base
docker push hunterlong/statping:vue
2020-02-28 07:56:17 +00:00
modd:
modd -f ./dev/modd.conf
2020-02-27 10:04:27 +00:00
top:
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml top
2019-12-18 11:36:29 +00:00
2020-02-27 10:04:27 +00:00
frontend-build:
2020-03-06 22:18:06 +00:00
rm -rf source/dist && rm -rf frontend/dist
cd frontend && yarn build
cp -r frontend/dist source/ && cp -r frontend/src/assets/scss source/dist/
2020-02-27 10:04:27 +00:00
cp -r source/tmpl/*.* source/dist/
2019-12-18 11:36:29 +00:00
# compile assets using SASS and Rice. compiles scss -> css, and run rice embed-go
2020-03-06 16:13:54 +00:00
compile: generate frontend-build
2020-03-06 22:18:06 +00:00
rm -f source/rice-box.go
2019-12-18 11:36:29 +00:00
cd source && rice embed-go
2018-08-14 04:13:06 +00:00
2020-03-06 22:18:06 +00:00
embed:
cd source && rice embed-go
build:
2020-02-27 10:04:27 +00:00
$(GOBUILD) $(BUILDVERSION) -o $(BINARY_NAME) ./cmd
2018-08-14 05:10:51 +00:00
2020-03-03 16:19:55 +00:00
install: build
2020-02-27 10:04:27 +00:00
mv $(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
2018-08-14 04:13:06 +00:00
2020-02-27 10:04:27 +00:00
generate:
cd source && go generate
2018-08-14 04:13:06 +00:00
# remove files for a clean compile/build
2018-08-14 04:13:06 +00:00
clean:
2019-12-29 21:06:12 +00:00
rm -rf ./{logs,assets,plugins,*.db,config.yml,.sass-cache,config.yml,statping,build,.sass-cache,index.html,vendor}
rm -rf cmd/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log,*.html,*.json}
rm -rf core/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log}
2020-03-09 15:15:15 +00:00
rm -rf types/notifications/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log}
2019-12-29 21:06:12 +00:00
rm -rf handlers/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log}
rm -rf notifiers/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log}
rm -rf source/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log}
rm -rf types/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log}
rm -rf utils/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log}
rm -rf dev/{logs,assets,plugins,*.db,config.yml,.sass-cache,*.log,test/app,plugin/*.so}
2018-11-29 04:47:35 +00:00
rm -rf {parts,prime,snap,stage}
2018-08-19 08:48:02 +00:00
rm -rf dev/test/cypress/videos
2018-08-25 16:10:28 +00:00
rm -f coverage.* sass
2018-11-07 09:28:46 +00:00
rm -f source/rice-box.go
rm -rf **/*.db-journal
2018-11-29 04:47:35 +00:00
rm -rf *.snap
find . -name "*.out" -type f -delete
find . -name "*.cpu" -type f -delete
find . -name "*.mem" -type f -delete
2020-03-03 06:42:37 +00:00
rm -rf {build,tmp}
2018-08-17 01:43:12 +00:00
2020-02-28 06:37:48 +00:00
print_details:
@echo \==== Statping Development Instance ====
@echo \Statping Vue Frontend: http://localhost:8888
@echo \Statping Backend API: http://localhost:8585
@echo \==== Statping Instances ====
@echo \Statping SQLite: http://localhost:4000
@echo \Statping MySQL: http://localhost:4005
@echo \Statping Postgres: http://localhost:4010
@echo \==== Databases ====
@echo \PHPMyAdmin: http://localhost:6000 \(MySQL database management\)
@echo \SQLite Web: http://localhost:6050 \(SQLite database management\)
@echo \PGAdmin: http://localhost:7000 \(Postgres database management \| email: admin@admin.com password: admin\)
@echo \Prometheus: http://localhost:7050 \(Prometheus Web UI\)
@echo \==== Monitoring and IDE ====
@echo \Grafana: http://localhost:3000 \(username: admin, password: admin\)
2020-03-06 03:03:18 +00:00
build-all: xgo-install build-mac build-linux build-windows build-linux build-alpine compress
2020-03-04 10:29:00 +00:00
download-key:
2020-03-04 14:20:47 +00:00
wget -O statping.gpg $(KEY_URL)
2020-03-04 10:29:00 +00:00
gpg --import statping.gpg
2020-03-03 16:19:55 +00:00
# build Statping for Mac, 64 and 32 bit
2020-03-04 10:29:00 +00:00
build-mac:
2020-03-03 16:19:55 +00:00
mkdir build
$(XGO) $(BUILDVERSION) --targets=darwin/amd64,darwin/386 ./cmd
# build Statping for Linux 64, 32 bit, arm6/arm7
2020-03-04 10:29:00 +00:00
build-linux:
2020-03-03 16:19:55 +00:00
$(XGO) $(BUILDVERSION) --targets=linux/amd64,linux/386,linux/arm-7,linux/arm-6,linux/arm64 ./cmd
# build for windows 64 bit only
2020-03-04 10:29:00 +00:00
build-windows:
2020-03-03 16:19:55 +00:00
$(XGO) $(BUILDVERSION) --targets=windows-6.0/amd64 ./cmd
# build Alpine linux binary (used in docker images)
2020-03-04 10:29:00 +00:00
build-alpine:
2020-03-03 16:19:55 +00:00
$(XGO) --targets=linux/amd64 -ldflags="-X main.VERSION=${VERSION} -X main.COMMIT=$(TRAVIS_COMMIT) -linkmode external -extldflags -static" -out alpine ./cmd
# build :latest docker tag
docker-build-latest:
docker build --build-arg VERSION=${VERSION} -t hunterlong/statping:latest --no-cache -f Dockerfile .
docker tag hunterlong/statping:latest hunterlong/statping:v${VERSION}
# compress built binaries into tar.gz and zip formats
2020-03-04 10:29:00 +00:00
compress: download-key
2020-03-03 16:19:55 +00:00
cd build && mv alpine-linux-amd64 $(BINARY_NAME)
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-alpine.tar.gz $(BINARY_NAME) statping.asc && rm -f $(BINARY_NAME) statping.asc
cd build && mv cmd-darwin-10.6-amd64 $(BINARY_NAME)
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-osx-x64.tar.gz $(BINARY_NAME) statping.asc && rm -f $(BINARY_NAME) statping.asc
cd build && mv cmd-darwin-10.6-386 $(BINARY_NAME)
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-osx-x32.tar.gz $(BINARY_NAME) statping.asc && rm -f $(BINARY_NAME) statping.asc
cd build && mv cmd-linux-amd64 $(BINARY_NAME)
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-x64.tar.gz $(BINARY_NAME) statping.asc && rm -f $(BINARY_NAME) statping.asc
cd build && mv cmd-linux-386 $(BINARY_NAME)
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-x32.tar.gz $(BINARY_NAME) statping.asc && rm -f $(BINARY_NAME) statping.asc
cd build && mv cmd-windows-6.0-amd64.exe $(BINARY_NAME).exe
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME).exe
cd build && zip $(BINARY_NAME)-windows-x64.zip $(BINARY_NAME).exe statping.asc && rm -f $(BINARY_NAME).exe statping.asc
cd build && mv cmd-linux-arm-7 $(BINARY_NAME)
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-arm7.tar.gz $(BINARY_NAME) statping.asc && rm -f $(BINARY_NAME) statping.asc
cd build && mv cmd-linux-arm-6 $(BINARY_NAME)
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-arm6.tar.gz $(BINARY_NAME) statping.asc && rm -f $(BINARY_NAME) statping.asc
cd build && mv cmd-linux-arm64 $(BINARY_NAME)
cd build && gpg --default-key $(SIGN_KEY) --batch --detach-sign --output statping.asc --armor $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-arm64.tar.gz $(BINARY_NAME) statping.asc && rm -f $(BINARY_NAME) statping.asc
# push the :dev docker tag using curl
publish-dev:
curl -H "Content-Type: application/json" --data '{"docker_tag": "dev"}' -X POST $(DOCKER)
# update the homebrew application to latest for mac
publish-homebrew:
curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token $(TRAVIS_API)" -d $(PUBLISH_BODY) https://api.travis-ci.com/repo/hunterlong%2Fhomebrew-statping/requests
upload_to_s3:
aws s3 cp ./source/css $(ASSETS_BKT) --recursive --exclude "*" --include "*.css"
aws s3 cp ./source/js $(ASSETS_BKT) --recursive --exclude "*" --include "*.js"
aws s3 cp ./source/font $(ASSETS_BKT) --recursive --exclude "*" --include "*.eot" --include "*.svg" --include "*.woff" --include "*.woff2" --include "*.ttf" --include "*.css"
aws s3 cp ./source/scss $(ASSETS_BKT) --recursive --exclude "*" --include "*.scss"
aws s3 cp ./install.sh $(ASSETS_BKT)
travis_s3_creds:
mkdir -p ~/.aws
echo "[default]\naws_access_key_id = ${AWS_ACCESS_KEY_ID}\naws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" > ~/.aws/credentials
# build Statping using a travis ci trigger
travis-build: travis_s3_creds upload_to_s3
curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token $(TRAVIS_API)" -d $(TRAVIS_BUILD_CMD) https://api.travis-ci.com/repo/hunterlong%2Fstatping/requests
curl -H "Content-Type: application/json" --data '{"docker_tag": "latest"}' -X POST $(DOCKER)
sign-all:
gpg --default-key $SIGN_KEY --detach-sign --armor statpinger
valid-sign:
gpg --verify statping.asc
# install xgo and pull the xgo docker image
xgo-install: clean
go get github.com/crazy-max/xgo
docker pull crazy-max/xgo:${GOVERSION}
2020-02-28 07:56:17 +00:00
.PHONY: all build build-all build-alpine test-all test test-api docker frontend up down print_details lite
2019-12-29 21:01:53 +00:00
.SILENT: travis_s3_creds