-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker.mk
71 lines (63 loc) · 2.19 KB
/
docker.mk
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
docker-base-image: substitute-sources substitute-docker
@docker image inspect $(BASE_DOCKER_TAG) > /dev/null 2>&1 || ( \
echo "Building base docker image." && \
export DOCKER_BUILDKIT=1 && \
docker image build \
--tag "$(BASE_DOCKER_TAG)" \
--file docker/base_ubuntu2204.dockerfile \
. \
)
docker-test-image: docker-base-image
@docker image inspect $(TEST_DOCKER_TAG) > /dev/null 2>&1 || \
docker image build \
--tag "$(TEST_DOCKER_TAG)" \
--file docker/test_ubuntu2204.dockerfile \
.
docker-test: docker-test-image
docker run --rm \
--volume $(PWD)/test:/usr/src/$(UTIL_NAME)/test \
"$(TEST_DOCKER_TAG)"
docker-autotest: docker-test-image docker-build-package
@if [ $(shell find . -maxdepth 1 -type f -name .env | wc --lines) != 1 ]; then \
echo "Requires '.env' file with provided GitHub token for running autotests."; \
exit 200; \
else \
docker run --rm \
--volume $(PWD)/$(DEBIAN_PACKAGES_PATH):/usr/src/$(UTIL_NAME)/$(DEBIAN_PACKAGES_PATH) \
--volume $(PWD)/test:/usr/src/$(UTIL_NAME)/test \
--env-file .env \
"$(TEST_DOCKER_TAG)" bash -c \
"apt-get install -y /usr/src/${UTIL_NAME}/${DEBIAN_PACKAGES_PATH}/${DEB_PKG_NAME}.deb && make autotest"; \
fi
docker-build-package: docker-test-image
docker run --rm \
--volume $(PWD)/$(DEBIAN_PACKAGES_PATH):/usr/src/$(UTIL_NAME)/$(DEBIAN_PACKAGES_PATH) \
--env IS_DEVELOPED=$(IS_DEVELOPED) \
--env USER_UID=$(USER_UID) \
--env USER_GID=$(USER_GID) \
"$(TEST_DOCKER_TAG)" bash -c \
"make package"
docker-image: docker-base-image docker-test-image
@if [ "$(REBUILD)" = "1" ]; then \
make clean-all docker-rmi ALL="$(ALL)"; \
fi
@(docker image inspect $(DOCKER_TAG) > /dev/null 2>&1 && \
echo "The image already exists. For rebuilding image provide REBUILD=1 argument.") || ( \
make docker-test && \
make docker-build-package && \
docker image build \
--tag "$(DOCKER_TAG)" \
--file docker/ubuntu2204.dockerfile \
. \
)
docker-run: docker-image
@touch .env
docker run --rm --tty --interactive \
--env-file .env \
"$(DOCKER_TAG)"
docker-rmi:
@docker rmi $(DOCKER_TAG) --force
@docker rmi $(TEST_DOCKER_TAG) --force
@if [ "$(ALL)" = "1" ]; then \
docker rmi $(BASE_DOCKER_TAG) --force; \
fi