-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (55 loc) · 1.88 KB
/
Makefile
File metadata and controls
63 lines (55 loc) · 1.88 KB
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
RUBY_VERSIONS=3.1 3.2 3.3 3.4
ARCHES=arm64 amd64
DOCKER_MOUNT_NAME=otel-ruby
##################################################
# Main method to build the gems & binaries
##################################################
.PHONY: all
all:
@$(MAKE) prepare-multiarch
@$(MAKE) bake-images
@for vers in $(RUBY_VERSIONS); do \
for arch in $(ARCHES); do \
echo "\n🚀 Handling gems for Ruby $$vers on $$arch"; \
($(MAKE) unmount-container/$$vers-$$arch || true); \
$(MAKE) mount-container/$$vers-$$arch; \
$(MAKE) copy-files/$$vers-$$arch; \
$(MAKE) unmount-container/$$vers-$$arch; \
done; \
done
@$(MAKE) cleanup
@echo "\n✅ All gems have been built and copied to the respective directories."
prepare-multiarch:
@echo "\n🚀 Bootstraping buildx with QEMU support"
@docker buildx create --name multiarch --driver docker-container --use || true
@docker buildx inspect --bootstrap
bake-images:
@echo "\n🚀 Building images"
@mkdir -p tmp
@docker buildx bake --file docker-bake.hcl
mount-container/%:
@echo "🧪 Mounting container"
@{ \
VERS=$$(echo "$*" | cut -d '-' -f 1); \
ARCH=$$(echo "$*" | cut -d '-' -f 2); \
docker load -i tmp/${DOCKER_MOUNT_NAME}-$*.tar; \
docker create --platform=linux/$${ARCH} --name ${DOCKER_MOUNT_NAME}-$* ${DOCKER_MOUNT_NAME}:$*; \
}
unmount-container/%:
@echo "🧪 Unmounting container"
@docker rm ${DOCKER_MOUNT_NAME}-$*
copy-files/%:
@echo "🧪 Copying files"
@{ \
VERS=$$(echo "$*" | cut -d '-' -f 1); \
ARCH=$$(echo "$*" | cut -d '-' -f 2); \
rm -rf ./$${VERS}/$${ARCH}; \
mkdir -p ./$${VERS}/$${ARCH}; \
docker cp ${DOCKER_MOUNT_NAME}-$*:/Gemfile.lock ./$${VERS}/$${ARCH}/Gemfile.lock; \
docker cp ${DOCKER_MOUNT_NAME}-$*:/usr/local/bundle ./$${VERS}/$${ARCH}/bundle; \
}
cleanup:
@echo "\n🚀 Cleaning up leftovers"
@rm -rf tmp
@docker buildx use default || docker context use default
@docker buildx rm multiarch