This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
/
Makefile
136 lines (97 loc) · 2.66 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
all: clean build-prod
IMAGE_NAME ?= "omisego/ewallet:latest"
IMAGE_BUILDER ?= "omisegoimages/ewallet-builder:v1.2"
IMAGE_BUILD_DIR ?= $(PWD)
ASSETS ?= cd apps/frontend/assets &&
ENV_DEV ?= env MIX_ENV=dev
ENV_TEST ?= env MIX_ENV=test
ENV_PROD ?= env MIX_ENV=prod
LANG := en_US.UTF-8
LC_ALL := en_US.UTF-8
#
# Setting-up
#
deps: deps-ewallet deps-assets
deps-ewallet:
mix deps.get
deps-assets:
$(ASSETS) npm install
.PHONY: deps deps-ewallet deps-assets
#
# Cleaning
#
clean: clean-ewallet clean-assets clean-test-assets
clean-ewallet:
rm -rf _build/
rm -rf deps/
clean-assets:
rm -rf apps/frontend/assets/node_modules
rm -rf apps/frontend/priv/static
clean-test-assets:
rm -rf private/
rm -rf public/
rm -rf _build/test/lib/url_dispatcher/priv/static/private/*
rm -rf _build/test/lib/url_dispatcher/priv/static/public/test-*
rm -rf _build/test/lib/url_dispatcher/priv/static/public/test/
.PHONY: clean clean-ewallet clean-assets clean-test-assets
#
# Linting
#
format:
mix format
check-format:
mix format --check-formatted 2>&1
check-credo:
$(ENV_TEST) mix credo 2>&1
check-dialyzer:
$(ENV_TEST) mix dialyzer --halt-exit-status 2>&1
check-assets:
$(ASSETS) npm run lint 2>&1
check-assets:
$(ASSETS) npm run lint 2>&1
.PHONY: format check-format check-credo
#
# Building
#
build-assets: deps-assets
$(ASSETS) npm run build
# If we call mix phx.digest without mix compile, mix release will silently fail
# for some reason. Always make sure to run mix compile first.
build-prod: deps-ewallet build-assets
$(ENV_PROD) mix do compile, phx.digest, release
build-dev: deps-ewallet build-assets
$(ENV_DEV) mix do compile, release dev
build-test: deps-ewallet
$(ENV_TEST) mix compile
.PHONY: build-assets build-prod build-dev build-test
#
# Testing
#
test: test-ewallet test-assets
test-ewallet: clean-test-assets build-test
$(ENV_TEST) mix do ecto.create, ecto.migrate, test
test-assets: build-assets
$(ASSETS) npm run test
.PHONY: test test-ewallet test-assets
#
# Docker
#
docker-prod:
docker run --rm -it \
-v $(PWD):/app \
-v $(IMAGE_BUILD_DIR)/deps:/app/deps \
-v $(IMAGE_BUILD_DIR)/apps/frontend/assets/node_modules:/app/apps/frontend/assets/node_modules \
-u root \
--entrypoint /bin/sh \
$(IMAGE_BUILDER) \
-c "cd /app && make build-prod"
docker-build:
docker build \
--build-arg release_version=$$(awk '/version:/ { gsub(/[^0-9a-z\.\-]+/, "", $$2); print $$2 }' $(PWD)/apps/ewallet/mix.exs) \
--cache-from $(IMAGE_NAME) \
-t $(IMAGE_NAME) \
.
docker: docker-prod docker-build
docker-push: docker
docker push $(IMAGE_NAME)
.PHONY: docker docker-prod docker-build docker-push