-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile.docker
175 lines (144 loc) · 7.59 KB
/
Makefile.docker
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
165
166
167
168
169
170
171
172
173
174
175
# -*- Makefile -*-
.PHONY: clean
.DEFAULT: containers
clean:
rm -rf builds/repos/*
docker ps -a | awk '/Exited/ {print $$1;}' | xargs docker rm
docker images | awk '/none|fpm-(fry|dockery)/ {print $$3;}' | xargs docker rmi
ARCH := amd64
ifeq ($(ARCH),)
PLATFORM :=
LIBARCH :=
else
PLATFORM := --platform $(ARCH)
LIBARCH := $(ARCH:arm64=arm64v8)/
endif
CONTAINERS:=container-focal container-jammy container-noble container-focal-usr-local container-jammy-usr-local container-noble-usr-local
.PHONY: containers $(CONTAINERS)
containers: $(CONTAINERS)
container-focal:
docker build -t "stkaes/logjam-tools:focal-latest-$(ARCH)" -f Dockerfile.focal --build-arg prefix=/opt/logjam --build-arg suffix="" --build-arg arch=$(LIBARCH) .
container-jammy:
docker build -t "stkaes/logjam-tools:jammy-latest-$(ARCH)" -f Dockerfile.jammy --build-arg prefix=/opt/logjam --build-arg suffix="" --build-arg arch=$(LIBARCH) .
container-noble:
docker build -t "stkaes/logjam-tools:noble-latest-$(ARCH)" -f Dockerfile.noble --build-arg prefix=/opt/logjam --build-arg suffix="" --build-arg arch=$(LIBARCH) .
container-focal-usr-local:
docker build -t "stkaes/logjam-tools:focal-usr-local-latest-$(ARCH)" -f Dockerfile.focal --build-arg prefix=/usr/local --build-arg suffix="-usr-local" --build-arg arch=$(LIBARCH) .
container-jammy-usr-local:
docker build -t "stkaes/logjam-tools:jammy-usr-local-latest-$(ARCH)" -f Dockerfile.jammy --build-arg prefix=/usr/local --build-arg suffix="-usr-local" --build-arg arch=$(LIBARCH) .
container-noble-usr-local:
docker build -t "stkaes/logjam-tools:noble-usr-local-latest-$(ARCH)" -f Dockerfile.noble --build-arg prefix=/usr/local --build-arg suffix="-usr-local" --build-arg arch=$(LIBARCH) .
TAG ?= latest
VERSION ?= $(cat VERSION.txt)
RELEASE:=release-focal release-jammy release-noble release-focal-usr-local release-jammy-usr-local release-noble-usr-local
.PHONY: release $(RELEASE)
release: $(RELEASE)
release-focal:
$(MAKE) $(MFLAGS) tag-focal push-focal TAG=$(VERSION) ARCH=$(ARCH)
release-jammy:
$(MAKE) $(MFLAGS) tag-jammy push-jammy TAG=$(VERSION) ARCH=$(ARCH)
release-noble:
$(MAKE) $(MFLAGS) tag-noble push-noble TAG=$(VERSION) ARCH=$(ARCH)
release-focal-usr-local:
$(MAKE) $(MFLAGS) tag-focal-usr-local push-focal-usr-local TAG=$(VERSION) ARCH=$(ARCH)
release-jammy-usr-local:
$(MAKE) $(MFLAGS) tag-jammy-usr-local push-jammy-usr-local TAG=$(VERSION) ARCH=$(ARCH)
release-noble-usr-local:
$(MAKE) $(MFLAGS) tag-noble-usr-local push-noble-usr-local TAG=$(VERSION) ARCH=$(ARCH)
TAGS:=tag-focal tag-jammy tag-noble tag-focal-usr-local tag-jammy-usr-local tag-noble-usr-local
.PHONY: tag $(TAGS)
tag: $(TAGS)
tag-focal:
docker tag "stkaes/logjam-tools:focal-latest-$(ARCH)" "stkaes/logjam-tools:focal-$(TAG)-$(ARCH)"
tag-jammy:
docker tag "stkaes/logjam-tools:jammy-latest-$(ARCH)" "stkaes/logjam-tools:jammy-$(TAG)-$(ARCH)"
tag-noble:
docker tag "stkaes/logjam-tools:noble-latest-$(ARCH)" "stkaes/logjam-tools:noble-$(TAG)-$(ARCH)"
tag-focal-usr-local:
docker tag "stkaes/logjam-tools:focal-usr-local-latest-$(ARCH)" "stkaes/logjam-tools:focal-usr-local-$(TAG)-$(ARCH)"
tag-jammy-usr-local:
docker tag "stkaes/logjam-tools:jammy-usr-local-latest-$(ARCH)" "stkaes/logjam-tools:jammy-usr-local-$(TAG)-$(ARCH)"
tag-noble-usr-local:
docker tag "stkaes/logjam-tools:noble-usr-local-latest-$(ARCH)" "stkaes/logjam-tools:noble-usr-local-$(TAG)-$(ARCH)"
PUSHES:=push-focal push-jammy push-noble push-focal-usr-local push-jammy-usr-local push-noble-usr-local
.PHONY: push $(PUSHES)
push: $(PUSHES)
push-focal:
docker push "stkaes/logjam-tools:focal-$(TAG)-$(ARCH)"
push-jammy:
docker push "stkaes/logjam-tools:jammy-$(TAG)-$(ARCH)"
push-noble:
docker push "stkaes/logjam-tools:noble-$(TAG)-$(ARCH)"
push-focal-usr-local:
docker push "stkaes/logjam-tools:focal-usr-local-$(TAG)-$(ARCH)"
push-jammy-usr-local:
docker push "stkaes/logjam-tools:jammy-usr-local-$(TAG)-$(ARCH)"
push-noble-usr-local:
docker push "stkaes/logjam-tools:noble-usr-local-$(TAG)-$(ARCH)"
PACKAGES:=package-focal package-focal-usr-local package-jammy package-jammy-usr-local package-noble package-noble-usr-local
.PHONY: packages $(PACKAGES)
packages: $(PACKAGES)
ifeq ($(V),1)
override V:=--verbose
else
override V:=
endif
package-focal:
LOGJAM_PREFIX=/opt/logjam bundle exec fpm-fry cook $(V) $(PLATFORM) --update=always stkaes/logjam-tools:focal-latest-$(ARCH)
mkdir -p packages/ubuntu/focal && mv *.deb packages/ubuntu/focal
package-jammy:
LOGJAM_PREFIX=/opt/logjam bundle exec fpm-fry cook $(V) $(PLATFORM) --update=always stkaes/logjam-tools:jammy-latest-$(ARCH)
mkdir -p packages/ubuntu/jammy && mv *.deb packages/ubuntu/jammy
package-noble:
LOGJAM_PREFIX=/opt/logjam bundle exec fpm-fry cook $(V) $(PLATFORM) --update=always stkaes/logjam-tools:noble-latest-$(ARCH)
mkdir -p packages/ubuntu/noble && mv *.deb packages/ubuntu/noble
package-focal-usr-local:
LOGJAM_PREFIX=/usr/local bundle exec fpm-fry cook $(V) $(PLATFORM) --update=always stkaes/logjam-tools:focal-usr-local-latest-$(ARCH)
mkdir -p packages/ubuntu/focal && mv *.deb packages/ubuntu/focal
package-jammy-usr-local:
LOGJAM_PREFIX=/usr/local bundle exec fpm-fry cook $(V) $(PLATFORM) --update=always stkaes/logjam-tools:jammy-usr-local-latest-$(ARCH)
mkdir -p packages/ubuntu/jammy && mv *.deb packages/ubuntu/jammy
package-noble-usr-local:
LOGJAM_PREFIX=/usr/local bundle exec fpm-fry cook $(V) $(PLATFORM) --update=always stkaes/logjam-tools:noble-usr-local-latest-$(ARCH)
mkdir -p packages/ubuntu/noble && mv *.deb packages/ubuntu/noble
LOGJAM_PACKAGE_HOST:=railsexpress.de
LOGJAM_PACKAGE_USER:=uploader
PUBLISHES:=publish-focal publish-jammy publish-noble publish-focal-usr-local publish-jammy-usr-local publish-noble-usr-local
.PHONY: publish $(PUBLISHES)
publish: $(PUBLISHES)
VERSION:=$(shell cat VERSION.txt)
PACKAGE_NAME:=logjam-tools_$(VERSION)_$(ARCH).deb
PACKAGE_NAME_USR_LOCAL:=logjam-tools-usr-local_$(VERSION)_$(ARCH).deb
define upload-package
@if ssh $(LOGJAM_PACKAGE_USER)@$(LOGJAM_PACKAGE_HOST) debian-package-exists $(1) $(2); then\
echo package $(1)/$(2) already exists on the server;\
else\
tmpdir=`ssh $(LOGJAM_PACKAGE_USER)@$(LOGJAM_PACKAGE_HOST) mktemp -d` &&\
rsync -vrlptDz -e "ssh -l $(LOGJAM_PACKAGE_USER)" packages/ubuntu/$(1)/$(2) $(LOGJAM_PACKAGE_HOST):$$tmpdir &&\
ssh $(LOGJAM_PACKAGE_USER)@$(LOGJAM_PACKAGE_HOST) add-new-debian-packages $(1) $$tmpdir;\
fi
endef
publish-focal:
$(call upload-package,focal,$(PACKAGE_NAME))
publish-jammy:
$(call upload-package,jammy,$(PACKAGE_NAME))
publish-noble:
$(call upload-package,noble,$(PACKAGE_NAME))
publish-focal-usr-local:
$(call upload-package,focal,$(PACKAGE_NAME_USR_LOCAL))
publish-jammy-usr-local:
$(call upload-package,jammy,$(PACKAGE_NAME_USR_LOCAL))
publish-noble-usr-local:
$(call upload-package,noble,$(PACKAGE_NAME_USR_LOCAL))
.PHONY: all
all: containers tag push release packages publish
.PHONY: show-focal show-jammy show-noble
show-focal:
docker run --rm -it -v `pwd`/packages/ubuntu/focal:/src ubuntu:focal bash -c 'dpkg -I /src/logjam-tools_$(VERSION)_$(ARCH).deb'
docker run --rm -it -v `pwd`/packages/ubuntu/focal:/src ubuntu:focal bash -c 'dpkg -c /src/logjam-tools_$(VERSION)_$(ARCH).deb'
show-jammy:
docker run --rm -it -v `pwd`/packages/ubuntu/jammy:/src ubuntu:jammy bash -c 'dpkg -I /src/logjam-tools_$(VERSION)_$(ARCH).deb'
docker run --rm -it -v `pwd`/packages/ubuntu/jammy:/src ubuntu:jammy bash -c 'dpkg -c /src/logjam-tools_$(VERSION)_$(ARCH).deb'
show-noble:
docker run --rm -it -v `pwd`/packages/ubuntu/noble:/src ubuntu:noble bash -c 'dpkg -I /src/logjam-tools_$(VERSION)_$(ARCH).deb'
docker run --rm -it -v `pwd`/packages/ubuntu/noble:/src ubuntu:noble bash -c 'dpkg -c /src/logjam-tools_$(VERSION)_$(ARCH).deb'