-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
79 lines (65 loc) · 1.82 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
BASE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ifeq ($(VERSION),)
VERSION := latest
endif
ifeq ($(REGISTRY),)
REGISTRY=craigcondit
endif
ifeq ($(HOST_ARCH),)
HOST_ARCH := $(shell uname -m)
endif
ifeq (x86_64, $(HOST_ARCH))
EXEC_ARCH := amd64
DOCKER_ARCH := amd64
else ifeq (i386, $(HOST_ARCH))
EXEC_ARCH := 386
DOCKER_ARCH := i386
else ifneq (,$(filter $(HOST_ARCH), arm64 aarch64))
EXEC_ARCH := arm64
DOCKER_ARCH := arm64v8
else ifeq (armv7l, $(HOST_ARCH))
EXEC_ARCH := arm
DOCKER_ARCH := arm32v7
else
$(info Unknown architecture "${HOST_ARCH}" defaulting to: amd64)
EXEC_ARCH := amd64
DOCKER_ARCH := amd64
endif
.PHONY: all
all:
$(MAKE) -C $(dir (BASE_DIR)) build image
.PHONY: build
build: bin/webdav-server.dev
.PHONY: build-release
build-release: bin/webdav-server
.PHONY: image
image: build-release Dockerfile
rm -rf .tmp/docker-dirs
mkdir -p .tmp/docker-dirs/root/conf .tmp/docker-dirs/user/content
DOCKER_BUILDKIT=1 \
docker build . -t "${REGISTRY}/webdav-server-${DOCKER_ARCH}:${VERSION}" \
--platform "linux/${DOCKER_ARCH}"
.PHONY: clean
clean:
@rm -rf bin sandbox .tmp
go clean -cache -testcache -r
sandbox:
@mkdir -p sandbox
bin/webdav-server.dev: sandbox cmd/**/*.go pkg/**/*.go
CGO_ENABLED=0 \
go build -a -ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo \
-o bin/webdav-server.dev ./cmd/webdav
bin/webdav-server: sandbox cmd/**/*.go pkg/**/*.go
CGO_ENABLED=0 GOOS=linux GOARCH="${EXEC_ARCH}" \
go build -a -ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo \
-o bin/webdav-server ./cmd/webdav
.PHONY:
run: build
bin/webdav-server.dev
run-docker: image
docker run -it --rm=true \
-p 8080:8080 \
-v "$(BASE_DIR)/sandbox:/content" \
-v "$(BASE_DIR)/conf:/conf" \
"${REGISTRY}/webdav-server-${DOCKER_ARCH}:${VERSION}"