You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

48 lines
1.2 KiB

VERSION=$(shell git describe --tags --abbrev=0)
BUILD=$(shell git rev-parse --short HEAD)
PROJECTNAME := $(shell basename "$(PWD)")
# Go related variables.
GOBASE := $(shell pwd)
GOPATH := $(GOBASE)/vendor:$(GOBASE)
GOBIN := $(GOBASE)/bin
GOFILES := main.go
LDFLAG=-X 'github.com/mutsuki333/calendar/cmd.Version=$(VERSION)-$(BUILD)'
LDFLAG+=-X 'github.com/mutsuki333/calendar/services.Version=$(VERSION)-$(BUILD)'
LDFLAGS=-ldflags="-w $(LDFLAG)"
# MAKEFLAGS += --silent
generate:
go generate
.PHONY: statik swagger
statik:
statik -src=ui/dist -dest=assets -f
swagger:
swag init -g services/services.go
build:
@echo " > Building binary..."
go build $(LDFLAGS) -o $(GOBIN)/$(PROJECTNAME) $(GOFILES)
debug: swagger build
all: generate build min
min:
@echo " > Building minimized binary..."
go build -tags min $(LDFLAGS) -o $(GOBIN)/$(PROJECTNAME)-min $(GOFILES)
docker-build:
docker build --target backend --cache-from=$(PROJECTNAME):backend -t $(PROJECTNAME):backend .
docker build --target release --cache-from=$(PROJECTNAME):backend -t $(PROJECTNAME) -t $(PROJECTNAME):$(VERSION) .
# -t $(PROJECTNAME):$(VERSION)-$(BUILD) .
docker-run: docker-build
docker run -it --rm --name $(PROJECTNAME) -p 8080:8080 $(PROJECTNAME)