38 lines
1.4 KiB
Makefile
38 lines
1.4 KiB
Makefile
GOCMD=go
|
|
GOBUILD=$(GOCMD) build
|
|
GOCLEAN=$(GOCMD) clean
|
|
GOTEST=$(GOCMD) test
|
|
RELEASE?=$(git describe --tags)
|
|
COMMIT?=$(shell git rev-parse --short HEAD)
|
|
BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
|
|
PROJECT?=github.com/BlackBroker/trashlog
|
|
GOOS?=linux
|
|
GOARCH?=amd64
|
|
BINARY_NAME=trashlog
|
|
PORT?=7113
|
|
|
|
all: build run
|
|
clean:
|
|
$(GOCLEAN)
|
|
rm -f $(BINARY_NAME)
|
|
build: clean
|
|
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} $(GOBUILD) \
|
|
-ldflags "-s -w -X ${PROJECT}/version.Release=${RELEASE} \
|
|
-X ${PROJECT}/version.Commit=${COMMIT} -X ${PROJECT}/version.BuildTime=${BUILD_TIME}" \
|
|
-o ${BINARY_NAME}
|
|
container: build
|
|
docker build -t $(BINARY_NAME):$(RELEASE) .
|
|
test:
|
|
$(GOTEST) -v -race ./...
|
|
install:
|
|
ifneq ($(shell dpkg --get-selections | grep "^docker-ce\s" | wc -l),1)
|
|
sudo apt-get update
|
|
sudo apt-get install -y ca-certificates curl gnupg lsb-release
|
|
sudo mkdir -p /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
echo "deb [arch=$(shell dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
sudo apt-get update
|
|
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
sudo usermod -aG docker ${USER}
|
|
endif
|