-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakefile
49 lines (38 loc) · 1.09 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
# Makefile for compiling Golang Linux installation package and frontend package
# TAG name for docker image
TAG ?= latest
# builder and cleaner
GO := go
GO_BUILD := $(GO) build
GO_CLEAN := $(GO) clean
GO_INSTALL := $(GO) install
NPM := npm
# cross-compiling Go for Linux
GOOS := linux
GOARCH := amd64
# Variables
WEB_SRC_DIR := frontend
SERVICE_SRC_DIR := backend
APP_NAME := micro-net-hub-$(GOOS)-$(GOARCH)
BIN_DIR := ../bin
GO_SRC := ./cmd/micro-net-hub/main.go
all: fe be dockerimage
be:
@echo "===== compile $(GOOS) $(GOARCH)... ====="
cd $(SERVICE_SRC_DIR) && env GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD) -o $(BIN_DIR)/$(APP_NAME) -trimpath $(GO_SRC)
@echo "target: $(BIN_DIR)/$(APP_NAME)"
fe:
@echo "===== compile webui... ====="
cd $(WEB_SRC_DIR) && npm run build:prod
# make dockerimage TAG=v0.2.2
dockerimage:
@echo "===== build docker image... ====="
docker build -t micro-net-hub:$(TAG) .
run:
@echo "===== use Air to start backend... ====="
cd $(SERVICE_SRC_DIR) && air
clean:
$(GO_CLEAN)
rm -f $(SERVICE_SRC_DIR)/$(BIN_DIR)/$(APP_NAME)
.DEFAULT_GOAL := all
.PHONY: all be fe clean run