forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
114 lines (87 loc) · 3.49 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
.PHONY: default all clean install install-ui ui assets lint lint-ui test build test-release release
.PHONY: docker publish-testing publish-latest publish-images
.PHONY: prepare-image image-rootfs image-update
.PHONY: soc server server-image
# build vars
TAG_NAME := $(shell test -d .git && git describe --abbrev=0 --tags)
SHA := $(shell test -d .git && git rev-parse --short HEAD)
VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA))
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
BUILD_TAGS := -tags=release
LD_FLAGS := -X github.com/andig/evcc/server.Version=$(VERSION) -X github.com/andig/evcc/server.Commit=$(SHA) -s -w
BUILD_ARGS := -ldflags='$(LD_FLAGS)'
# docker
DOCKER_IMAGE := andig/evcc
ALPINE_VERSION := 3.13
TARGETS := arm.v6,arm.v8,amd64
# image
IMAGE_FILE := evcc_$(TAG_NAME).image
IMAGE_ROOTFS := evcc_$(TAG_NAME).rootfs
IMAGE_OPTIONS := -hostname evcc -http_port 8080 github.com/gokrazy/serial-busybox github.com/gokrazy/breakglass github.com/andig/evcc
default: build
all: clean install install-ui ui assets lint lint-ui test build
clean:
rm -rf dist/
install:
go install github.com/golang/mock/mockgen
install-ui:
npm ci
ui:
npm run build
assets:
go generate ./...
lint:
golangci-lint run
lint-ui:
npm run lint
test:
@echo "Running testsuite"
go test ./...
build:
@echo Version: $(VERSION) $(BUILD_DATE)
go build -v $(BUILD_TAGS) $(BUILD_ARGS)
release-test:
goreleaser --snapshot --skip-publish --rm-dist
release:
goreleaser --rm-dist
docker:
@echo Version: $(VERSION) $(BUILD_DATE)
docker build --tag $(DOCKER_IMAGE):testing .
publish-testing:
@echo Version: $(VERSION) $(BUILD_DATE)
seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \
--image-name $(DOCKER_IMAGE) -v "testing" --targets=$(TARGETS)
publish-latest:
@echo Version: $(VERSION) $(BUILD_DATE)
seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \
--image-name $(DOCKER_IMAGE) -v "latest" --targets=$(TARGETS)
publish-images:
@echo Version: $(VERSION) $(BUILD_DATE)
seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \
--image-name $(DOCKER_IMAGE) -v "latest" -v "$(TAG_NAME)" --targets=$(TARGETS)
prepare-image:
go get github.com/gokrazy/tools/cmd/gokr-packer@latest
mkdir -p flags/github.com/gokrazy/breakglass
echo "-forward=private-network" > flags/github.com/gokrazy/breakglass/flags.txt
mkdir -p buildflags/github.com/andig/evcc
echo "$(BUILD_TAGS),gokrazy" > buildflags/github.com/andig/evcc/buildflags.txt
echo "-ldflags=$(LD_FLAGS)" >> buildflags/github.com/andig/evcc/buildflags.txt
image:
gokr-packer -overwrite=$(IMAGE_FILE) -target_storage_bytes=1258299392 $(IMAGE_OPTIONS)
loop=$$(sudo losetup --find --show -P $(IMAGE_FILE)); sudo mkfs.ext4 $${loop}p4
gzip -f $(IMAGE_FILE)
image-rootfs:
gokr-packer -overwrite_root=$(IMAGE_ROOTFS) $(IMAGE_OPTIONS)
gzip -f $(IMAGE_ROOTFS)
image-update:
gokr-packer -update yes $(IMAGE_OPTIONS)
soc:
@echo Version: $(VERSION) $(BUILD_DATE)
go build -o evcc-soc $(BUILD_TAGS) $(BUILD_ARGS) github.com/andig/evcc/soc/client
server:
@echo Version: $(VERSION) $(BUILD_DATE)
go build -o soc-server $(BUILD_TAGS) $(BUILD_ARGS) github.com/andig/evcc/soc/server
publish-server:
GOOS=linux GOARCH=amd64 go build -o soc-server $(BUILD_TAGS) $(BUILD_ARGS) github.com/andig/evcc/soc/server
docker build -f soc/Dockerfile --platform linux/amd64 -t andig/evcc-cloud .
docker push andig/evcc-cloud