Skip to content

Commit a266027

Browse files
tamalsahaknadh
authored andcommitted
Build static Go binary
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent b060c75 commit a266027

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

Makefile

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,43 @@ deps:
1717
go get -u github.com/knadh/stuffbin/...
1818
cd frontend && yarn install
1919

20-
# Run the JS frontend server in dev mode.
21-
.PHONY: run-frontend
22-
run-frontend:
23-
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn serve
24-
25-
# Build the JS frontend into frontend/dist.
26-
.PHONY: build-frontend
27-
build-frontend:
28-
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn build
20+
# Build the backend to ./listmonk.
21+
.PHONY: build
22+
build:
23+
CGO_ENABLED=0 go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}'" cmd/*.go
2924

3025
# Run the backend.
3126
.PHONY: run
3227
run: build
3328
./${BIN}
3429

35-
# Build the backend to ./listmonk.
36-
.PHONY: build
37-
build:
38-
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}'" cmd/*.go
30+
# Build the JS frontend into frontend/dist.
31+
.PHONY: build-frontend
32+
build-frontend:
33+
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn build
3934

40-
# pack-releases runns stuffbin packing on the given binary. This is used
41-
# in the .goreleaser post-build hook.
42-
.PHONY: pack-bin
43-
pack-bin:
44-
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
35+
# Run the JS frontend server in dev mode.
36+
.PHONY: run-frontend
37+
run-frontend:
38+
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn serve
39+
40+
# Run Go tests.
41+
.PHONY: test
42+
test:
43+
go test ./...
4544

4645
# Bundle all static assets including the JS frontend into the ./listmonk binary
4746
# using stuffbin (installed with make deps).
4847
.PHONY: dist
4948
dist: build build-frontend
5049
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
5150

51+
# pack-releases runns stuffbin packing on the given binary. This is used
52+
# in the .goreleaser post-build hook.
53+
.PHONY: pack-bin
54+
pack-bin:
55+
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
56+
5257
# Use goreleaser to do a dry run producing local builds.
5358
.PHONY: release-dry
5459
release-dry:
@@ -58,13 +63,3 @@ release-dry:
5863
.PHONY: release
5964
release:
6065
goreleaser --parallelism 1 --rm-dist --skip-validate
61-
62-
# Opens the cypress frontend tests UI.
63-
.PHONY: open-frontend-tests
64-
open-frontend-tests:
65-
cd frontend && ./node_modules/cypress/bin/cypress open
66-
67-
# Run Go tests.
68-
.PHONY: test
69-
test:
70-
go test ./...

0 commit comments

Comments
 (0)