-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (75 loc) · 2.47 KB
/
Makefile
File metadata and controls
112 lines (75 loc) · 2.47 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
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
# MKDEV 0.9.0 (x-release-please-version)
# See <https://github.com/ttybitnik/mkdev> for more information.
PROJECT_NAME = diego
CONTAINER_ENGINE = podman
RUN_BIND_SOCKET = false
EXEC_SHELL_CMD := /bin/bash
RM := /bin/rm -f
__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...)
golangci-lint run
test: lint
$(info Running tests...)
go test -cover -race ./internal/adapters/left/cli
build: test
$(info Building...)
go build -o $(PROJECT_NAME) main.go
run: build
$(info Running...)
./$(PROJECT_NAME)
deploy: build
$(info Deploying...)
goreleaser build --snapshot --clean
debug: test
$(info Debugging tasks...)
go build -gcflags=all="-N -l" -o $(PROJECT_NAME) main.go
distclean:
$(info Cleaning artifacts...)
$(RM) -r -- ./$(PROJECT_NAME) ./dist/
update:
go get -u ./...
go mod tidy
$(MAKE) run
golden: lint
go test -cover ./internal/adapters/left/cli -update
$(MAKE) run