-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
87 lines (69 loc) · 3 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
# Makefile for mimock
APP_CONFIG_FILE := 'classpath:/application.yml'
APP_DB_URL := 'jdbc:postgresql://localhost:5427/mimock_db'
TEST_CONFIG_FILE := 'classpath:/application.test.yml'
TEST_DB_URL := 'jdbc:postgresql://localhost:5427/mimock_db'
STATIC_DIR := '../mimock-backend/src/main/resources/static/mimock-ui'
VERSION := $$MIMOCK_CURRENT_VERSION
ifdef SKIP_TESTS
BUILD_BACKEND := cd ./mimock-backend && ./mvnw -ntp clean package -Dmaven.test.skip=true -Drevision=$(VERSION) && cd ..
BUILD_UI := cd ./mimock-ui && yarn && NODE_NEV=production yarn build
else
BUILD_UI := cd ./mimock-ui && yarn && yarn test && NODE_NEV=production yarn build
BUILD_BACKEND := cd ./mimock-backend && ./mvnw -ntp clean package -Drevision=$(VERSION) && cd ..
endif
cd_backend:
cd ./mimock-backend
generate-mvnw: cd_backend
mvn -N io.takari:maven:wrapper; cd ..
create-network:
@docker network inspect mimock-network >/dev/null 2>&1 || \
docker network create mimock-network
start-database: create-network
@docker build -t mimock-pg-database . -f Dockerfile.pg
@docker inspect mimock-db --format "imageName: {{.Id}}" || docker run --name mimock-db -p 5432:5432 --network mimock-network -d mimock-pg-database
start-app-local: start-database
./mimock-backend/mvnw clean spring-boot:run -Dspring.config.location=$(APP_CONFIG_FILE) -Dspring.datasource.url=$(APP_DB_URL)
format-check:
./mimock-backend/mvnw checkstyle:check
format-report:
./mimock-backend/mvnw clean site
test-local: start-database
./mimock-backend/mvnw clean test -Dspring.config.location=$(TEST_CONFIG_FILE) -Dspring.datasource.url=$(TEST_DB_URL) -P startDatabase
test-ci:
docker-compose -f docker-compose.test.yml up --abort-on-container-exit --exit-code-from mimock-test
build-app:
@echo "Building mimock bundle" && \
$(BUILD_UI) && \
mkdir -p $(STATIC_DIR) && \
mv ./dist/* ../mimock-backend/src/main/resources/static/mimock-ui/ && cd .. && \
$(BUILD_BACKEND)
bundle-app: start-database build-app
build-docker-image:
@echo "Building docker image" && \
docker build -t mimock/mimock:$(VERSION) . -f ./Dockerfile.slim
generate-keystore:
@echo "Generating keystore" && \
keytool -genkeypair -noprompt \
-alias mimock \
-keyalg RSA \
-keysize 4096 \
-storetype PKCS12 \
-dname "CN=mimock.io, OU=mimock, O=airbindo, L=CH, S=TN, C=IN" \
-keystore mimock-keystore.p12 \
-validity 3650 \
-keypass ironclaw \
-storepass ironclaw && \
mv mimock-keystore.p12 ./mimock-backend/src/main/resources/keystore
start-app-container: generate-keystore bundle-app build-docker-image
@echo "Starting mimock docker container" && \
docker run -d --name mimock -p 8080:8080 --network mimock-network \
--env MIMOCK_KEYSTORE_ENABLE=true \
--env MIMOCK_KEYSTORE_PATH=classpath:/keystore/mimock-keystore.p12 \
--env MIMOCK_KEYSTORE_PASSWORD=ironclaw \
--env MIMOCK_DB_SCHEMA=mimock_schema_dev \
--env MIMOCK_DB_URL=jdbc:postgresql://mimock-db:5432/mimock_db \
--env MIMOCK_DB_USER=mimock \
--env MIMOCK_DB_PASSWORD=ironclaw \
--env MIMOCK_LOG_LEVEL=INFO \
mimock/mimock:$(VERSION)