-
Notifications
You must be signed in to change notification settings - Fork 107
/
Makefile
executable file
·81 lines (78 loc) · 3.18 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
PROJECT_NAME=dpanel
GO_SOURCE_DIR=$(shell pwd)
GO_TARGET_DIR=$(GO_SOURCE_DIR)/runtime
TRIM_PATH=/Users/renchao
JS_SOURCE_DIR=$(GO_SOURCE_DIR)/../../js/d-panel
VERSION=1.0.0
COMMON_PARAMS=-ldflags '-s -w' -gcflags="all=-trimpath=${TRIM_PATH}" -asmflags="all=-trimpath=${TRIM_PATH}"
FAMILY=ce
help:
@echo "make build"
@echo "make test VERSION="
@echo "make all r1 r2 VERSION="
@echo "make clean"
amd64:
# brew tap messense/macos-cross-toolchains && brew install x86_64-linux-musl
# apk add musl
CGO_ENABLED=1 GOARCH=amd64 GOOS=linux CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++ \
go build ${COMMON_PARAMS} -tags ${FAMILY} -o ${GO_TARGET_DIR}/${PROJECT_NAME}-musl-amd64 ${GO_SOURCE_DIR}/*.go
cp ${GO_SOURCE_DIR}/config.yaml ${GO_TARGET_DIR}/config.yaml
arm64:
# brew tap messense/macos-cross-toolchains && brew install aarch64-unknown-linux-musl
# apk add musl
CGO_ENABLED=1 GOARM=7 GOARCH=arm64 GOOS=linux CC=aarch64-unknown-linux-musl-gcc CXX=aarch64-unknown-linux-musl-g++ \
go build ${COMMON_PARAMS} -tags ${FAMILY} -o ${GO_TARGET_DIR}/${PROJECT_NAME}-musl-arm64 ${GO_SOURCE_DIR}/*.go
cp ${GO_SOURCE_DIR}/config.yaml ${GO_TARGET_DIR}/config.yaml
armv7:
# brew tap messense/macos-cross-toolchains && brew install armv7-unknown-linux-musleabihf
# apk add musl
CGO_ENABLED=1 GOARM=7 GOARCH=arm GOOS=linux CC=armv7-unknown-linux-musleabihf-gcc CXX=armv7-unknown-linux-musleabihf-g++ \
go build ${COMMON_PARAMS} -tags ${FAMILY} -o ${GO_TARGET_DIR}/${PROJECT_NAME}-musl-arm ${GO_SOURCE_DIR}/*.go
cp ${GO_SOURCE_DIR}/config.yaml ${GO_TARGET_DIR}/config.yaml
build:
CGO_ENABLED=1 go build ${COMMON_PARAMS} -o ${GO_TARGET_DIR}/${PROJECT_NAME} ${GO_SOURCE_DIR}/*.go
cp ${GO_SOURCE_DIR}/config.yaml ${GO_TARGET_DIR}/config.yaml
js:
rm -f ${GO_SOURCE_DIR}/asset/static/*.js ${GO_SOURCE_DIR}/asset/static/*.css ${GO_SOURCE_DIR}/asset/static/index.html
cd ${JS_SOURCE_DIR} && npm run build && cp -r ${JS_SOURCE_DIR}/dist/* ${GO_SOURCE_DIR}/asset/static
clean-source:
go clean
rm -f \
${GO_TARGET_DIR}/config.yaml \
${GO_TARGET_DIR}/${PROJECT_NAME}-amd64 \
${GO_TARGET_DIR}/${PROJECT_NAME}-arm64 \
${GO_TARGET_DIR}/${PROJECT_NAME}-arm \
${GO_TARGET_DIR}/${PROJECT_NAME}
clean:
docker buildx prune -a -f
docker stop buildx_buildkit_dpanel-builder0 && docker rm /buildx_buildkit_dpanel-builder0
all: clean-source js amd64 arm64 armv7
test:
docker buildx build \
-t registry.cn-hangzhou.aliyuncs.com/dpanel/dpanel:${VERSION}-lite \
--platform linux/arm64,linux/amd64 \
--build-arg APP_VERSION=${VERSION} \
-f Dockerfile-lite \
. --push
# docker buildx build \
# -t registry.cn-hangzhou.aliyuncs.com/dpanel/dpanel:${VERSION} \
# --platform linux/arm64,linux/amd64 \
# --build-arg APP_VERSION=${VERSION} \
# --build-arg PROXY="https_proxy=http://172.16.1.198:7890 http_proxy=http://172.16.1.198:7890" \
# -f Dockerfile \
# . --push
demo: amd64
docker buildx build \
-t registry.cn-hangzhou.aliyuncs.com/dpanel/dpanel:demo \
--platform linux/amd64 \
--build-arg APP_VERSION=${VERSION} \
-f Dockerfile-demo \
. --push
pe:
docker buildx build \
-t registry.cn-hangzhou.aliyuncs.com/dpanel/dpanel:pe \
--platform linux/amd64 \
--build-arg APP_VERSION=${VERSION} \
--build-arg APP_FAMILY=pe \
-f Dockerfile \
. --push