first commit
This commit is contained in:
41
Makefile
Normal file
41
Makefile
Normal file
@@ -0,0 +1,41 @@
|
||||
.PHONY: build run test test-race lint clean docker tidy install-systemd
|
||||
|
||||
GO ?= go
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
||||
LDFLAGS := -s -w -X main.version=$(VERSION)
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 $(GO) build -ldflags "$(LDFLAGS)" -o bin/nip05api ./cmd/nip05api
|
||||
|
||||
run:
|
||||
$(GO) run ./cmd/nip05api
|
||||
|
||||
test:
|
||||
$(GO) test ./... -count=1
|
||||
|
||||
test-race:
|
||||
$(GO) test ./... -race -count=1
|
||||
|
||||
lint:
|
||||
golangci-lint run
|
||||
|
||||
tidy:
|
||||
$(GO) mod tidy
|
||||
|
||||
clean:
|
||||
rm -rf bin/ .data/
|
||||
|
||||
docker:
|
||||
docker build --build-arg VERSION=$(VERSION) -t nip05api:$(VERSION) -t nip05api:latest .
|
||||
|
||||
# Install onto a Linux host running systemd. Run as root.
|
||||
# Assumes the binary has already been built into ./bin/nip05api.
|
||||
install-systemd:
|
||||
id nip05 >/dev/null 2>&1 || useradd -r -s /usr/sbin/nologin -d /opt/nip05api nip05
|
||||
install -d -m 0755 -o nip05 -g nip05 /opt/nip05api/.data
|
||||
install -d -m 0755 -o nip05 -g nip05 /opt/nip05api/bin
|
||||
install -m 0755 -o nip05 -g nip05 bin/nip05api /opt/nip05api/bin/nip05api
|
||||
install -m 0644 -o nip05 -g nip05 messages.example.yaml /opt/nip05api/messages.yaml
|
||||
install -m 0644 -o root -g root deploy/nip05api.service /etc/systemd/system/nip05api.service
|
||||
systemctl daemon-reload
|
||||
@echo "Installed. Now: copy your .env to /opt/nip05api/.env, then 'systemctl enable --now nip05api'."
|
||||
Reference in New Issue
Block a user