forked from arriven/db1000n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (49 loc) · 1.77 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
APP_NAME := db1000n
ifeq ($(GOOS),windows)
APP_NAME := $(addsuffix .exe,$(APP_NAME))
endif
REPOSITORY_BASE_PATH := github.com/Arriven/db1000n
LATEST_TAG := $(shell git describe --tags --abbrev=0)
# Remove debug information (ELF) to strip the binary size
LDFLAGS += -s -w
ifneq ($(LATEST_TAG),)
LDFLAGS += -X '$(REPOSITORY_BASE_PATH)/src/utils/ota.Version=$(LATEST_TAG)'
endif
ifneq ($(ENCRYPTION_KEYS),)
LDFLAGS += -X '$(REPOSITORY_BASE_PATH)/src/utils.EncryptionKeys=$(ENCRYPTION_KEYS)'
BUILD_TAGS += encrypted
endif
ifneq ($(DEFAULT_CONFIG_VALUE),)
LDFLAGS += -X '$(REPOSITORY_BASE_PATH)/src/job/config.DefaultConfig=$(DEFAULT_CONFIG_VALUE)'
endif
ifneq ($(CA_PATH_VALUE),)
LDFLAGS += -X '$(REPOSITORY_BASE_PATH)/src/utils/metrics.PushGatewayCA=$(CA_PATH_VALUE)'
endif
ifneq ($(PROMETHEUS_BASIC_AUTH),)
LDFLAGS += -X '$(REPOSITORY_BASE_PATH)/src/utils/metrics.BasicAuth=$(PROMETHEUS_BASIC_AUTH)'
endif
build:
CGO_ENABLED=0 go build -ldflags="${LDFLAGS}" -tags="${BUILD_TAGS}" -o $(APP_NAME) -a ./main.go
build_encrypted: build
encrypt_config:
@if [ "$(DEFAULT_CONFIG)" = "" ]; then \
echo "Not specified DEFAULT_CONFIG"; \
else \
file=`tempfile` && \
age --encrypt -p --output $${file} $(DEFAULT_CONFIG) && \
echo "Saved in file: $${file}"; \
config=`cat $${file} | base64 | tr -d '\n'` && \
echo "Save value as env variable: \nexport DEFAULT_CONFIG_VALUE='$${config}'"; \
fi
encrypt_ca:
@if [ "$(CA_PATH)" = "" ]; then \
echo "Not specified CA_PATH"; \
else \
file=`tempfile` && \
age --encrypt -p --output $${file} $(CA_PATH) && \
echo "Saved in file: $${file}"; \
config=`cat $${file} | base64 | tr -d '\n'` && \
echo "Save value as env variable: \nexport CA_PATH_VALUE='$${config}'"; \
fi
docker_build:
@docker build -t "ghcr.io/arriven/db1000n" -f Dockerfile .