-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
55 lines (41 loc) · 1.79 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
SHELL := bash
.PHONY : help fmt build-image container-start app
.DEFAULT_GOAL := help
IMAGE_NAME = gopherbin
CONTAINER_NAME = gopher
CONFIG_FILE = $(PWD)/testdata/config.toml
GOPATH ?= $(shell go env GOPATH)
help :
@echo "Variables:"
@echo " IMAGE_NAME -> docker image name. Default = gopherbin"
@echo " CONTAINER_NAME -> container name. Default = gopher"
@echo " CONFIG_FILE -> your gopherbin config file(see testdata directory) which will be mounted inside the container"
@echo
@echo "Usage:"
@echo " make fmt -> running gofmt with options -s(simplify code) and -l (list files)"
@echo " make submodules -> initialize the web UI submodule"
@echo " make noUI -> build gopherbin without the web UI"
@echo " make withUI -> build gopherbin with the web UI (requires nodejs and yarn to be installed)"
@echo " make all-noui -> shorthand for make fmt submodules noUI"
@echo " make all -> shorthand for make fmt submodules withUI"
@echo " make build-image -> create a docker image with gopher binary"
@echo " make container-start -> start ghoperbin container"
@echo " make app -> build go binary and start a container with it"
fmt:
gofmt -s -l .
submodules:
git submodule update --init --recursive
buildUI:
cd webui/web && npm install && yarn build --production
noUI:
go install -mod vendor -ldflags="-s -w" ./cmd/...
withUI:
go install -mod vendor -ldflags="-s -w -X 'gopherbin/webui.BuildTime=$(shell date +%s)'" -tags webui ./cmd/...
all-noui: fmt submodules noUI
all: fmt submodules buildUI withUI
build-image:
docker build --no-cache --tag $(IMAGE_NAME) .
docker image prune -f --filter label=stage=builder
container-start :
docker run --rm -p 9997:9997 --name $(CONTAINER_NAME) -v $(CONFIG_FILE):/etc/gopherbin-config.toml -d $(IMAGE_NAME)
app: build-image container-start