blog/Makefile

59 lines
1.5 KiB
Makefile
Raw Permalink Normal View History

2017-10-08 04:48:58 +00:00
SHELL := /bin/bash
VERSION=$(shell grep -e 'Version' blog.go | head -n 1 | cut -d '"' -f 2)
BUILD=$(shell git describe --always)
2018-06-07 18:51:44 +00:00
CURDIR=$(shell pwd)
2017-10-08 04:48:58 +00:00
# Inject the build version (commit hash) into the executable.
LDFLAGS := -ldflags "-X main.Build=$(BUILD)"
# `make setup` to set up a new environment, pull dependencies, etc.
.PHONY: setup
setup: clean
go get -u ./...
# `make build` to build the binary.
.PHONY: build
build:
gofmt -w .
go build $(LDFLAGS) -i -o bin/blog cmd/blog/main.go
2017-10-08 04:48:58 +00:00
2020-10-29 01:56:09 +00:00
# `make bindata` to make the bindata module.
# `make bindata-dev` for debug mode module for editing files locally.
.PHONY: bindata bindata-dev
bindata:
go-bindata -pkg root -prefix root/ -o src/root/bundle.go root/...
bindata-dev:
go-bindata -debug -pkg root -prefix root/ -o src/root/bundle.go root/...
2017-10-08 04:48:58 +00:00
# `make run` to run it in debug mode.
.PHONY: run
run:
2018-04-11 02:07:25 +00:00
./go-reload cmd/blog/main.go -debug user-root
2017-10-08 04:48:58 +00:00
# `make test` to run unit tests.
.PHONY: test
test:
go test ./...
# `make clean` cleans everything up.
.PHONY: clean
clean:
rm -rf bin dist
2017-11-15 14:55:15 +00:00
# `make hardclean` cleans EVERY THING, including root/.private, resetting
# your database in the local dev environment. Be careful!
.PHONY: hardclean
hardclean: clean
rm -rf root/.private
2018-06-07 18:51:44 +00:00
# `make docker.build` to build the Docker image
.PHONY: docker.build
docker.build:
docker build -t blog .
# `make docker.run` to run the docker image
.PHONY: docker.run
docker.run:
2018-09-18 18:21:11 +00:00
docker run --rm --name blog_debug -p 8000:80 -v "$(CURDIR)/user-root:/data/www:z" blog