-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (75 loc) · 2.55 KB
/
Copy pathMakefile
File metadata and controls
98 lines (75 loc) · 2.55 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
# Generated by usvc-1.13.4
# Feel free to adjust, it will not be overridden
.PHONY: image.build image.run image.test image.push image.pull
.PHONY: create-deploy deploy k8s-shell console watch lint
.PHONY: config-gen abort-on-uncommited-changes copy-mix.lock db.init
SEMAPHORE_EXECUTABLE_UUID?=""
GIT_HASH=$(shell git log --format=format:'%h' -1)
TAG?=$(GIT_HASH)-$(SEMAPHORE_EXECUTABLE_UUID)
REPO=renderedtext/sys2app
IMAGE=$(REPO):$(TAG)
IMAGE_LATEST=$(REPO):latest
HOME_DIR=/home/dev
WORKDIR=$(HOME_DIR)/sys2app
USER=dev
MIX_ENV=dev
CONTAINER_ENV_VARS= \
-e MIX_ENV=$(MIX_ENV) \
INTERACTIVE_SESSION=\
-v $$PWD/home_dir:$(HOME_DIR) \
-v $$PWD:$(WORKDIR) \
--rm \
--workdir=$(WORKDIR) \
--user=$(USER) \
-it renderedtext/elixir-dev:1.5.1-v2
CMD?=/bin/bash
console:
docker run --network=host $(CONTAINER_ENV_VARS) $(INTERACTIVE_SESSION) $(CMD)
image.build:
docker build --cache-from $(IMAGE_LATEST) -t $(IMAGE) .
docker tag $(IMAGE) $(IMAGE_LATEST)
image.run: image.build
docker run -p 4000:4000 -it $(IMAGE)
# Container litens on different port
# (so that container and 'mix run' can run together)
image.test: image.build
docker run --rm --name sys2app -p 4004:4000 -d $(IMAGE)
# run some tests...
docker kill sys2app
create-deploy: abort-on-uncommited-changes image.push config-gen
kubectl create -f deploy.yml
kubectl get svc/sys2app
deploy: abort-on-uncommited-changes image.push config-gen
kubectl apply -f deploy.yml
kubectl get svc/sys2app
k8s-shell:
$(eval pod_name=$(shell kubectl get po -l app=cluster-portal -o jsonpath={.items[*].metadata.name}))
kubectl exec -it $(pod_name) -- /bin/bash
watch:
docker run --network=host $(CONTAINER_ENV_VARS) $(INTERACTIVE_SESSION) \
mix do deps.get, test.watch
lint:
$(MAKE) console CMD="mix do credo"
lint-root:
$(MAKE) console USER=root CMD="mix do local.hex --force, local.rebar --force, deps.get, credo"
postgres.run:
docker run -d --rm --name db --network=host postgres:9.6
@echo "\nWaiting for DB to become operational"
sleep 5
$(MAKE) db.init
db.init:
$(MAKE) console MIX_ENV=$(MIX_ENV) USER=$(USER) CMD="mix do ecto.create, ecto.migrate"
@echo "\nDatabase '$(DB_NAME)' created and migrated."
@echo "\nConnect with: 'psql -h localhost -U postgres $(DB_NAME)'"
image.push: image.build
docker push $(IMAGE)
docker push $(IMAGE_LATEST)
image.pull:
docker pull $(IMAGE)
docker pull $(IMAGE_LATEST)
usvc.install:
mix archive.install http://usvc.tools.renderedtext.com/usvc-1.13.4.ez --force
config-gen:
mix usvc.cfg_gen $(TAG)
abort-on-uncommited-changes:
git diff-index --quiet HEAD --