first commit
This commit is contained in:
65
Makefile
Normal file
65
Makefile
Normal file
@@ -0,0 +1,65 @@
|
||||
BINARY = paste
|
||||
MODULE = ridgwaysystems.org/paste
|
||||
CMD = ./cmd/server
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
go build -o $(BINARY) $(CMD)
|
||||
|
||||
.PHONY: run
|
||||
run:
|
||||
DEV=1 PORT=8081 go run $(CMD)
|
||||
|
||||
.PHONY: run-env
|
||||
run-env:
|
||||
@test -f .env || (echo "No .env file found. Copy .env.example and fill it in." && exit 1)
|
||||
env $$(cat .env | grep -v '^\#' | xargs) go run $(CMD)
|
||||
|
||||
.PHONY: cross
|
||||
cross:
|
||||
GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w" -o $(BINARY)-freebsd-amd64 $(CMD)
|
||||
|
||||
.PHONY: genhash
|
||||
genhash:
|
||||
@read -p "Password: " pw && go run ./tools/genhash "$$pw"
|
||||
|
||||
.PHONY: tidy
|
||||
tidy:
|
||||
go mod tidy
|
||||
|
||||
.PHONY: vet
|
||||
vet:
|
||||
go vet ./...
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(BINARY) $(BINARY)-freebsd-amd64
|
||||
rm -f static/css/syntax.css
|
||||
|
||||
DEPLOY_HOST ?= srv01
|
||||
DEPLOY_DIR ?= /var/www/paste
|
||||
|
||||
.PHONY: deploy
|
||||
deploy: cross
|
||||
ssh $(DEPLOY_HOST) "rcctl stop $(BINARY); pkill $(BINARY); true"
|
||||
scp $(BINARY)-freebsd-amd64 $(DEPLOY_HOST):/usr/local/bin/$(BINARY)
|
||||
rsync -av --delete templates/ $(DEPLOY_HOST):$(DEPLOY_DIR)/templates/
|
||||
rsync -av --delete static/ $(DEPLOY_HOST):$(DEPLOY_DIR)/static/
|
||||
ssh $(DEPLOY_HOST) rcctl start $(BINARY)
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "Targets:"
|
||||
@echo " build Build binary for current OS"
|
||||
@echo " run Run locally in dev mode (port 8081)"
|
||||
@echo " run-env Run with .env file"
|
||||
@echo " cross Cross-compile for FreeBSD amd64"
|
||||
@echo " genhash Generate bcrypt hash for admin password"
|
||||
@echo " tidy go mod tidy"
|
||||
@echo " vet go vet"
|
||||
@echo " deploy Cross-compile and deploy to server"
|
||||
@echo " clean Remove build artifacts"
|
||||
Reference in New Issue
Block a user