forked from ayufan/pve-backup-server-dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (128 loc) · 5.05 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
BUILD_ARCHS = amd64 arm64v8
CLIENT_BUILD_ARCHS = amd64 arm64v8
REGISTRY ?= ayufan/proxmox-backup-server
VERSION ?= $(shell ls versions | grep -E -v '.(tmp|debug)' | sort -V | tail -n 1)
TAG ?= $(VERSION)
ifneq (,$(wildcard .env.mk))
include .env.mk
endif
# Architectures
arm32v7-%: DOCKER_ARCH=arm32v7
arm64v8-%: DOCKER_ARCH=arm64v8
amd64-%: DOCKER_ARCH=amd64
dev-%:
# Docker Images
%-docker-build:
docker build \
--tag $(REGISTRY):$(TAG)-$* \
--build-arg ARCH=$(addsuffix /,$(DOCKER_ARCH)) \
--build-arg TAG=$(TAG) \
--build-arg VERSION=$(VERSION) \
-f versions/$(VERSION)/Dockerfile \
.
docker-build: $(addsuffix -docker-build, $(BUILD_ARCHS))
# Docker Hub Images
%-dockerhub: %-docker-build
docker push $(REGISTRY):$(TAG)-$*
%-dockerhub-pull:
docker pull $(REGISTRY):$(TAG)-$*
dockerhub-manifest: $(addsuffix -dockerhub-pull, $(BUILD_ARCHS))
# This requires `echo '{"experimental":"enabled"}' > ~/.docker/config.json`
-rm -rf ~/.docker/manifests
docker manifest create $(REGISTRY):$(TAG) \
$(addprefix $(REGISTRY):$(TAG)-, $(BUILD_ARCHS))
docker manifest push $(REGISTRY):$(TAG)
dockerhub: $(addsuffix -dockerhub, $(BUILD_ARCHS))
make dockerhub-manifest
%-dockerhub-latest-release: %-dockerhub-pull
docker tag $(REGISTRY):$(TAG)-$* $(REGISTRY):latest-$*
docker push $(REGISTRY):latest-$*
dockerhub-latest-release: $(addsuffix -dockerhub-latest-release, $(BUILD_ARCHS))
# This requires `echo '{"experimental":"enabled"}' > ~/.docker/config.json`
-rm -rf ~/.docker/manifests
docker manifest create $(REGISTRY):latest \
$(addprefix $(REGISTRY):$(TAG)-, $(BUILD_ARCHS))
docker manifest push $(REGISTRY):latest
# Client Binaries
%-client:
docker build \
--tag $(REGISTRY):$(TAG)-client-$* \
--build-arg DOCKER_ARCH=$(DOCKER_ARCH) \
--build-arg TAG=$(TAG) \
--build-arg VERSION=$(VERSION) \
-f versions/$(VERSION)/Dockerfile.client \
.
mkdir -p release/$(TAG)
docker run --rm $(REGISTRY):$(TAG)-client-$* sh -c 'cat /proxmox-backup-client*.tgz' > release/$(TAG)/proxmox-backup-client-$(VERSION)-$*.tgz
client: $(addsuffix -client, $(CLIENT_BUILD_ARCHS))
# Debian Packages
%-deb: %-dockerhub-pull
mkdir -p release/$(TAG)
-docker rm -f proxmox-backup-$(TAG)-$*
docker create --name=proxmox-backup-$(TAG)-$* $(REGISTRY):$(TAG)-$*
docker cp proxmox-backup-$(TAG)-$*:/deb/. release/$(TAG)/$*
-docker rm -f proxmox-backup-$(TAG)-$*
deb: $(addsuffix -deb, $(BUILD_ARCHS))
# Development Helpers
tmp-env:
mkdir -p "tmp/$(VERSION)"
cd "tmp/$(VERSION)" && ../../versions/$(VERSION)/clone.bash
cd "tmp/$(VERSION)" && ../../scripts/apply-patches.bash ../../versions/$(VERSION)/server/*.patch
cd "tmp/$(VERSION)" && ../../scripts/strip-cargo.bash
cd "tmp/$(VERSION)" && ../../scripts/resolve-dependencies.bash
tmp-env-client:
mkdir -p "tmp/$(VERSION)-client"
cd "tmp/$(VERSION)-client" && ../../versions/$(VERSION)/clone.bash
cd "tmp/$(VERSION)-client" && ../../scripts/apply-patches.bash ../../versions/$(VERSION)/server/*.patch ./../versions/$(VERSION)/client*/*.patch
cd "tmp/$(VERSION)-client" && ../../scripts/strip-cargo.bash
cd "tmp/$(VERSION)-client" && ../../scripts/resolve-dependencies.bash
tmp-docker-shell:
docker build \
--tag tmp-docker-shell \
--build-arg ARCH=$(addsuffix /,$(DOCKER_ARCH)) \
--build-arg TAG=$(TAG) \
--build-arg VERSION=$(VERSION) \
--target toolchain \
-f versions/$(VERSION)/Dockerfile \
.
docker run --name=tmp-docker-shell --net=host --rm -it \
-v "$(CURDIR):$(CURDIR)" \
-w "$(CURDIR)/tmp/$(VERSION)" \
tmp-docker-shell
dev-run: dev-docker-build
-docker rm -f proxmox-backup
docker run --name=proxmox-backup --net=host --tmpfs /run --rm $(REGISTRY):$(TAG)-dev
dev-shell: dev-docker-build
-docker rm -f proxmox-backup
docker run --name=proxmox-backup -it --tmpfs /run --rm $(REGISTRY):$(TAG)-dev /bin/bash
# Version management
fork-version:
ifndef NEW_VERSION
@echo "Missing 'make fork-version NEW_VERSION=...'"
@exit 1
endif
rm -rf "versions/v$(NEW_VERSION).tmp"
cp -rv "versions/$(VERSION)" "versions/v$(NEW_VERSION).tmp"
"versions/v$(NEW_VERSION).tmp/clone.bash" show-sha $(firstword $(NEW_SHA) $(NEW_VERSION)) > "versions/v$(NEW_VERSION).tmp/versions.tmp"
mv "versions/v$(NEW_VERSION).tmp/versions.tmp" "versions/v$(NEW_VERSION).tmp/versions"
mv "versions/v$(NEW_VERSION).tmp" "versions/v$(NEW_VERSION)"
release: dockerhub client deb
# GitHub Releases
export GITHUB_USER ?= ayufan
export GITHUB_REPO ?= pve-backup-server-dockerfiles
github-upload-all:
@set -e; for file in release/$(TAG)/*.tgz release/$(TAG)/*/*.deb; do \
echo "Uploading $$file..."; \
github-release upload -t $(TAG) -R -n $$(basename $$file) -f $$file; \
done
github-pre-release:
rm -rf release/$(TAG)
make release
github-release --version || go get github.com/github-release/github-release
git push
github-release info -t $(TAG) || github-release release -t $(TAG) --draft --description "$$(cat RELEASE.md)"
make github-upload-all
github-release edit -t $(TAG) --pre-release --description "$$(cat RELEASE.md)"
github-latest-release:
github-release edit -t $(TAG) --description "$$(cat RELEASE.md)"
make dockerhub-latest-release