summaryrefslogtreecommitdiffhomepage
path: root/tools/unitctl/build/container.mk
blob: c892db2e1abcec224c3b1a21aeda0277ee811c45 (plain) (blame)
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
 ## Builds a container image for building on Debian Linux
.PHONY: container-debian-build-image
.ONESHELL: container-debian-build-image
container-debian-build-image:
container-debian-build-image:
	$Q echo "$(M) building debian linux docker build image: $(@)"
	$(DOCKER) buildx build $(DOCKER_BUILD_FLAGS)\
		-t debian_builder -f Dockerfile $(CURDIR);

 ## Builds deb packages using a container image
.PHONY: container-deb-packages
container-deb-packages: container-debian-build-image
	$Q $(DOCKER) run --rm --volume "$(CURDIR):/project" \
		--workdir /project debian_builder make deb-packages
	# Reset permissions on the target directory to the current user
	if command -v id > /dev/null; then \
		$(DOCKER) run --rm --volume "$(CURDIR):/project" \
			--workdir /project debian_builder \
			chown --recursive "$(shell id -u):$(shell id -g)" /project/target
	fi

 ## Builds a rpm packages using a container image
.PHONY: container-rpm-packages
container-rpm-packages: container-debian-build-image
	$Q $(DOCKER) run --rm --volume "$(CURDIR):/project" \
		--workdir /project debian_builder make rpm-packages
	# Reset permissions on the target directory to the current user
	if command -v id > /dev/null; then \
		$(DOCKER) run --rm --volume "$(CURDIR):/project" \
			--workdir /project debian_builder chown --recursive \
			"$(shell id -u):$(shell id -g)" /project/target
	fi

## Builds all packages using a container image
.PHONY: container-all-packages
container-all-packages: container-debian-build-image
	$Q $(DOCKER) run --rm --volume "$(CURDIR):/project" \
		--workdir /project debian_builder make all-packages
	# Reset permissions on the target directory to the current user
	if command -v id > /dev/null; then \
		$(DOCKER) run --rm --volume "$(CURDIR):/project" \
			--workdir /project debian_builder \
			chown --recursive "$(shell id -u):$(shell id -g)" /project/target
	fi

## Run tests inside container
.PHONY: container-test
container-test: container-debian-build-image
	$Q $(DOCKER) run --rm --volume "$(CURDIR):/project" \
		--workdir /project debian_builder make test
	# Reset permissions on the target directory to the current user
	if command -v id > /dev/null; then \
		$(DOCKER) run --rm --volume "$(CURDIR):/project" \
			--workdir /project debian_builder \
			chown --recursive "$(shell id -u):$(shell id -g)" /project/target
	fi

.PHONY: container-shell
container-shell: container-debian-build-image ## Run tests inside container
	$Q $(DOCKER) run -it --rm --volume "$(CURDIR):/project" \
		--workdir /project debian_builder bash
	# Reset permissions on the target directory to the current user
	if command -v id > /dev/null; then \
		$(DOCKER) run --rm --volume "$(CURDIR):/project" \
			--workdir /project debian_builder \
			chown --recursive "$(shell id -u):$(shell id -g)" /project/target
	fi