-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
94 lines (65 loc) · 2.19 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
# MKDEV 0.4.0 (x-release-please-version)
# See <https://github.com/ttybitnik/mkdev> for more information.
PROJECT_NAME = changeme
CONTAINER_ENGINE = changeme
RUN_BIND_SOCKET = false
EXEC_SHELL_CMD = /bin/bash
__USER = $(or $(USER),$(shell whoami))
__SOCKET = /run/user/$(shell id -u)/podman/podman.sock
# Host targets/commands
.PHONY: dev start open stop clean serestore
dev:
$(info Building development container image...)
$(CONTAINER_ENGINE) build \
--build-arg USERNAME=$(__USER) \
-f .mkdev/Containerfile \
-t localhost/mkdev/$(PROJECT_NAME) \
.
start:
$(info Starting development container...)
$(CONTAINER_ENGINE) run -it -d --replace \
$(if $(filter podman,$(CONTAINER_ENGINE)),--userns=keep-id) \
--name mkdev-$(PROJECT_NAME) \
--volume .:/home/$(__USER)/workspace:Z \
$(if $(filter true,$(RUN_BIND_SOCKET)),--volume $(__SOCKET):$(__SOCKET)) \
$(if $(filter true,$(RUN_BIND_SOCKET)),--env CONTAINER_HOST=unix://$(__SOCKET)) \
localhost/mkdev/$(PROJECT_NAME):latest
@# $(CONTAINER_ENGINE) compose .mkdev/compose.yaml up -d
open:
$(info Opening development container...)
$(CONTAINER_ENGINE) exec -it mkdev-$(PROJECT_NAME) $(EXEC_SHELL_CMD)
stop:
$(info Stopping development container...)
$(CONTAINER_ENGINE) stop mkdev-$(PROJECT_NAME)
@# $(CONTAINER_ENGINE) compose .mkdev/compose.yaml down
clean: distclean
$(info Removing development container and image...)
-$(CONTAINER_ENGINE) rm mkdev-$(PROJECT_NAME)
-$(CONTAINER_ENGINE) image rm localhost/mkdev/$(PROJECT_NAME)
@# $(CONTAINER_ENGINE) image prune
serestore:
$(info Restoring project SELinux context and permissions...)
chcon -Rv unconfined_u:object_r:user_home_t:s0 .
# find . -type d -exec chmod 700 {} \;
# find . -type f -exec chmod 600 {} \;
# Container targets/commands
.PHONY: lint test build run deploy debug distclean
lint:
$(info Running linters...)
ansible-lint
yamllint .
test: lint
$(info Running tests...)
molecule -c molecule/resources/molecule.yml test \
$(if $(scenario),-s $(scenario)) \
$(if $(platform),-p $(platform))
build: test
$(info Building...)
run: build
$(info Running...)
deploy: build
$(info Deploying...)
debug: test
$(info Debugging tasks...)
distclean:
$(info Cleaning artifacts...)