-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (52 loc) · 1.59 KB
/
Makefile
File metadata and controls
64 lines (52 loc) · 1.59 KB
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
ENV := $(shell cat ../../.last_used_env || echo "not-set")
-include ../../.env.${ENV}
BUILD := $(shell git rev-parse --short HEAD)
LDFLAGS=-ldflags "-X=main.commitSHA=$(BUILD)"
AWS_BUCKET_PREFIX ?= $(PREFIX)$(AWS_ACCOUNT_ID)-
GCP_BUCKET_PREFIX ?= $(GCP_PROJECT_ID)-
# Architecture for builds. Defaults to local arch; override for cross-compilation
# (e.g., BUILD_ARCH=amd64 make build from an ARM64 host).
BUILD_ARCH ?= $(shell go env GOARCH)
# Docker platform string. Override for cross-platform builds:
# BUILD_PLATFORM=linux/arm64 make start-docker
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)
.PHONY: init
init:
brew install protobuf
upload:
chmod +x bin/envd
ifeq ($(PROVIDER),aws)
aws s3 cp ./bin/envd "s3://${AWS_BUCKET_PREFIX}fc-env-pipeline/envd" --profile ${AWS_PROFILE} --cache-control "no-cache, max-age=0"
else
gsutil -h "Cache-Control:no-cache, max-age=0" cp bin/envd "gs://${GCP_BUCKET_PREFIX}fc-env-pipeline/envd"
endif
build:
CGO_ENABLED=0 GOOS=linux GOARCH=$(BUILD_ARCH) go build -a -o bin/envd ${LDFLAGS}
build-debug:
CGO_ENABLED=1 go build -race -gcflags=all="-N -l" -o bin/debug/envd ${LDFLAGS}
start-docker:
make build
DOCKER_BUILDKIT=1 docker build --platform $(BUILD_PLATFORM) -t envd-debug . -f debug.Dockerfile
docker run \
--name envd \
--platform $(BUILD_PLATFORM) \
-p 49983:49983 \
-p 2345:2345 \
-p 9999:9999 \
-p 8000:8000 \
-p 8001:8001 \
--rm \
-i envd-debug \
/usr/bin/envd -isnotfc
build-and-upload:
make build
make upload
.PHONY: generate
generate:
go generate ./...
.PHONY: test
test:
go test -race -v ./...
.PHONY: lint
lint:
golangci-lint run --fix ./...