File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -6,20 +6,24 @@ ROOT_DIR=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
6
6
# Gather all .go files for use in dependencies below
7
7
GO_FILES =$(shell find $(ROOT_DIR ) -name '* .go')
8
8
9
- mod-tidy :
10
- go mod tidy
11
-
12
- # Build our program binary
13
- # Depends on GO_FILES to determine when rebuild is needed
14
- $(BINARY ) : mod-tidy $(GO_FILES )
15
- # Needed to fetch new dependencies and add them to go.mod
16
- go build -o $(BINARY ) ./cmd/$(BINARY )
9
+ GO_LDFLAGS =-ldflags "-s -w"
17
10
18
11
.PHONY : build image mod-tidy
19
12
20
13
# Alias for building program binary
21
14
build : $(BINARY )
22
15
16
+ # Build our program binary
17
+ # Depends on GO_FILES to determine when rebuild is needed
18
+ $(BINARY ) : mod-tidy $(GO_FILES )
19
+ CGO_ENABLED=0 go build \
20
+ $(GO_LDFLAGS ) \
21
+ -o $(BINARY ) \
22
+ ./cmd/$(BINARY )
23
+
24
+ mod-tidy :
25
+ go mod tidy
26
+
23
27
# Build docker image
24
28
image : build
25
29
docker build -t $(BINARY ) .
You can’t perform that action at this time.
0 commit comments