forked from pagopa/pagopa-fdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-and-run.sh
65 lines (57 loc) · 1.86 KB
/
build-and-run.sh
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
#!/bin/bash
action=$1
if [ -z "$action" ]; then
echo "Missed action: <build|run|generate_openapi|test_curl>"
exit 0
fi
REPO=pagopa/pagopafdr
build () {
conf=$1
version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Build version [$version] [$conf]"
#./mvnw clean package -Pnative -Dquarkus.native.container-build=true -Dquarkus.profile=$conf
#docker build -f src/main/docker/Dockerfile.native -t $REPO:$version-$conf .
docker build -f src/main/docker/Dockerfile.multistage --build-arg APP_NAME=pagopafdr --build-arg QUARKUS_PROFILE=$conf -t $REPO:$version-$conf .
}
run () {
conf=$1
version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Run version [$version] [$conf]"
docker run -i --rm --network=docker-infra_infra -p 8080:8080 $REPO:$version-$conf
}
generate_openapi () {
conf=$1
version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Generate OpenAPI JSON [$version] [$conf]"
docker run -i -d --name exportopenapifdr --rm -p 8080:8080 $REPO:$version-$conf
sleep 5
curl http://localhost:8080/q/openapi?format=json > openapi/openapi.json
docker rm -f exportopenapifdr
}
test_curl () {
curl localhost:8080/q/dev
curl localhost:8080/q/health
curl localhost:8080/q/health/live
curl localhost:8080/q/health/ready
curl localhost:8080/q/metrics
curl localhost:8080/q/swagger-ui
curl localhost:8080/q/openapi
}
if echo "build run generate_openapi test_curl" | grep -w $action > /dev/null; then
if [ $action = "build" ]; then
build docker
elif [ $action = "run" ]; then
echo "###########"
echo "# REQUIRED: run-local-infra.sh"
echo "###########"
run docker
elif [ $action = "generate_openapi" ]; then
build openapi
generate_openapi openapi
else
test_curl
fi
else
echo "Action [$action] not allowed."
exit 1
fi