forked from factorysh/docker-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
248 lines (203 loc) · 6.91 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
include Makefile.lint
include Makefile.build_args
.PHONY: rubies
RUBY_INSTALL_VERSION=0.8.1
# 2.3 is in Stretch
RUBY23 := 2.3.8
RUBY24 := 2.4.10
RUBY25 := 2.5.8
RUBY26 := 2.6.7
RUBY27 := 2.7.3
RUBY30 := 3.0.1
GOSS_VERSION := 0.3.9
USER=$(shell id -u)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
STRETCH_ID=$(shell docker images bearstech/debian:stretch --format="{{.ID}}" --quiet)
STRETCH_DEV_ID=$(shell docker images bearstech/debian-dev:stretch --format="{{.ID}}" --quiet)
BUSTER_ID=$(shell docker images bearstech/debian:buster --format="{{.ID}}" --quiet)
BUSTER_DEV_ID=$(shell docker images bearstech/debian-dev:buster --format="{{.ID}}" --quiet)
BULLSEYE_ID=$(shell docker images bearstech/debian:bullseye --format="{{.ID}}" --quiet)
BULLSEYE_DEV_ID=$(shell docker images bearstech/debian-dev:bullseye --format="{{.ID}}" --quiet)
DOCKERFILE_APT=$(shell sha1sum Dockerfile.apt | cut -c 1-40)
DOCKERFILE_APT_DEV=$(shell sha1sum Dockerfile.apt-dev | cut -c 1-40)
DOCKERFILE_RUBY_INSTALL=$(shell sha1sum Dockerfile.ruby-install | cut -c 1-40)
DOCKERFILE_RUBY_INSTALL_DEV=$(shell sha1sum Dockerfile.ruby-install-dev | cut -c 1-40)
DOCKERFILE_SINATRA_DEV=$(shell sha1sum Dockerfile.sinatra-dev | cut -c 1-40)
DOCKERFILE_TOOL=$(shell sha1sum Dockerfile.tool | cut -c 1-40)
MK23=$(shell sha1sum ruby23.mk | cut -c 1-40)
MK24=$(shell sha1sum ruby24.mk | cut -c 1-40)
MK25=$(shell sha1sum ruby25.mk | cut -c 1-40)
MK26=$(shell sha1sum ruby26.mk | cut -c 1-40)
MK27=$(shell sha1sum ruby27.mk | cut -c 1-40)
MK30=$(shell sha1sum ruby30.mk | cut -c 1-40)
DONE23=image-$(STRETCH_ID)_$(MK23)-$(DOCKERFILE_APT)-$(DOCKERFILE_APT_DEV)-2.3.done
DONE24=image-$(STRETCH_ID)_$(MK24)-$(DOCKERFILE_RUBY_INSTALL)-$(DOCKERFILE_RUBY_INSTALL_DEV)-$(RUBY24).done
DONE25=image-$(STRETCH_ID)_$(MK25)-$(DOCKERFILE_RUBY_INSTALL)-$(DOCKERFILE_RUBY_INSTALL_DEV)-$(RUBY25).done
DONE26=image-$(STRETCH_ID)_$(MK26)-$(DOCKERFILE_RUBY_INSTALL)-$(DOCKERFILE_RUBY_INSTALL_DEV)-$(RUBY26).done
DONE27=image-$(STRETCH_ID)_$(MK27)-$(DOCKERFILE_RUBY_INSTALL)-$(DOCKERFILE_RUBY_INSTALL_DEV)-$(RUBY27).done
DONE30=image-$(BULLSEYE_ID)_$(MK30)-$(DOCKERFILE_RUBY_INSTALL)-$(DOCKERFILE_RUBY_INSTALL_DEV)-$(RUBY30).done
DONE_SINATRA=image-$(STRETCH_DEV_ID)-$(GIT_VERSION)-$(BRANCH)-sinatra.done
include *.mk
all: pull build
pull:
docker pull bearstech/debian:stretch
push:
docker push bearstech/ruby:2.3
docker push bearstech/ruby-dev:2.3
docker push bearstech/ruby:2.4
docker push bearstech/ruby-dev:2.4
docker push bearstech/ruby:2.5
docker push bearstech/ruby-dev:2.5
docker push bearstech/ruby:2.6
docker push bearstech/ruby-dev:2.6
docker push bearstech/ruby:2.7
docker push bearstech/ruby-dev:2.7
docker push bearstech/ruby:2.7-bullseye
docker push bearstech/ruby-dev:2.7-bullseye
docker push bearstech/ruby:3.0
docker push bearstech/ruby-dev:3.0
docker push bearstech/sinatra-dev
remove_image:
docker rmi bearstech/ruby:2.3
docker rmi bearstech/ruby-dev:2.3
docker rmi bearstech/ruby:2.4
docker rmi bearstech/ruby-dev:2.4
docker rmi bearstech/ruby:2.5
docker rmi bearstech/ruby-dev:2.5
docker rmi bearstech/ruby:2.6
docker rmi bearstech/ruby-dev:2.6
docker rmi bearstech/ruby:2.7
docker rmi bearstech/ruby-dev:2.7
docker rmi bearstech/ruby:2.7-bullseye
docker rmi bearstech/ruby-dev:2.7-bullseye
docker rmi bearstech/ruby:3.0
docker rmi bearstech/ruby-dev:3.0
docker rmi bearstech/sinatra-dev
build: | \
tools \
done23 \
done24 \
done25 \
done26 \
done27 \
done30 \
done-sinatra \
image-2.7-bullseye \
image-2.7-dev-bullseye
done:
mkdir -p done
done23:
ifeq (,$(wildcard done/$(DONE23)))
$(MAKE) done/$(DONE23)
endif
done24:
ifeq (,$(wildcard done/$(DONE24)))
$(MAKE) done/$(DONE24)
endif
done25:
ifeq (,$(wildcard done/$(DONE25)))
$(MAKE) done/$(DONE25)
endif
done26:
ifeq (,$(wildcard done/$(DONE26)))
$(MAKE) done/$(DONE26)
endif
done27:
ifeq (,$(wildcard done/$(DONE27)))
$(MAKE) done/$(DONE27)
endif
done30:
ifeq (,$(wildcard done/$(DONE30)))
$(MAKE) done/$(DONE30)
endif
done-sinatra:
ifeq (,$(wildcard done/$(DONE_SINATRA)))
$(MAKE) done/$(DONE_SINATRA)
endif
done/$(DONE23): | done image-2.3 image-2.3-dev test-2.3
rm -f done/image-*-2.3.done
touch done/$(DONE23)
done/$(DONE24): | done image-2.4 image-2.4-dev test-2.4
rm -f done/image-*-2.4.*.done
touch done/$(DONE24)
done/$(DONE25): | done image-2.5 image-2.5-dev test-2.5
rm -f done/image-*-2.5.*.done
touch done/$(DONE25)
done/$(DONE26): | done image-2.6 image-2.6-dev test-2.6
rm -f done/image-*-2.6.*.done
touch done/$(DONE26)
done/$(DONE27): | done image-2.7 image-2.7-dev test-2.7
rm -f done/image-*-2.7.*.done
touch done/$(DONE27)
done/$(DONE30): | done image-3.0 image-3.0-dev test-3.0
rm -f done/image-*-3.0.*.done
touch done/$(DONE30)
done/$(DONE_SINATRA): | done image-sinatra-dev
rm -f done/image-*-sinatra.done
touch done/$(DONE_SINATRA)
## Docker ignore utils
ignore_all_rubies:
echo "rubies" > .dockerignore
DOCKER_IGNORE_RUBIES_DIR_REV := ""
DOCKER_IGNORE_RUBIES_DEPTH := "2"
rubies_docker_ignore:
find rubies \
-mindepth $(DOCKER_IGNORE_RUBIES_DEPTH) \
-maxdepth $(DOCKER_IGNORE_RUBIES_DEPTH) | \
(grep -v $(DOCKER_IGNORE_RUBIES_DIR_REV) || true) > .dockerignore
## Tools
tool-stretch:
make -C . ignore_all_rubies
docker build \
$(DOCKER_BUILD_ARGS) \
-t ruby-install:stretch \
-f Dockerfile.tool \
--build-arg RUBY_INSTALL_VERSION=$(RUBY_INSTALL_VERSION) \
--build-arg DEBIAN_DISTRO=stretch \
.
tool-buster:
make -C . ignore_all_rubies
docker build \
$(DOCKER_BUILD_ARGS) \
-t ruby-install:buster \
-f Dockerfile.tool \
--build-arg RUBY_INSTALL_VERSION=$(RUBY_INSTALL_VERSION) \
--build-arg DEBIAN_DISTRO=buster \
.
tool-bullseye:
make -C . ignore_all_rubies
docker build \
$(DOCKER_BUILD_ARGS) \
-t ruby-install:bullseye \
-f Dockerfile.tool \
--build-arg RUBY_INSTALL_VERSION=$(RUBY_INSTALL_VERSION) \
--build-arg DEBIAN_DISTRO=bullseye \
.
tools: tool-stretch tool-buster tool-bullseye
image-sinatra-dev:
make -C . ignore_all_rubies
docker build \
$(DOCKER_BUILD_ARGS) \
-t bearstech/sinatra-dev \
-f Dockerfile.sinatra-dev \
.
image-dev: image-2.3-dev image-2.4-dev image-2.5-dev image-2.6-dev image-2.7-dev image-2.7-dev-bullseye image-3.0-dev
image: image-2.3 image-2.4 image-2.5 image-2.6 image-2.7 image-2.7-bullseye image-3.0
images: image image-dev
clean:
rm -rf rubies bin done
rm .dockerignore
bin/goss-$(GOSS_VERSION):
mkdir -p bin
curl -o bin/goss-$(GOSS_VERSION) -L https://github.com/aelsabbahy/goss/releases/download/v${GOSS_VERSION}/goss-linux-amd64
chmod +x bin/goss-$(GOSS_VERSION)
bin/goss: bin/goss-$(GOSS_VERSION)
ln -sf goss-$(GOSS_VERSION) bin/goss
tests_ruby/test_install_db/bin/goss: bin/goss
mkdir -p tests_ruby/test_install_db/bin
cp -r bin/goss-$(GOSS_VERSION) tests_ruby/test_install_db/bin/goss-$(GOSS_VERSION)
cp -r bin/goss tests_ruby/test_install_db/bin/goss
goss: tests_ruby/test_install_db/bin/goss
test-all: | test-2.3 test-2.4 test-2.5 test-2.6 test-2.7 test-2.7-bullseye test-3.0
down:
tests: test-all