-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
idserver.sh
executable file
·160 lines (126 loc) · 4.23 KB
/
idserver.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env bash
config="debug"
# Getting the bash script executing path. See: https://stackoverflow.com/a/630387
base_dir="$(dirname -- "${BASH_SOURCE[0]}")" # relative
base_dir="$(cd -- "$base_dir" && pwd)" # absolutized and normalized
if [[ -z "$base_dir" ]]; then
echo "the path is not accessible"
exit 1
fi
source_dir="$base_dir/src"
build_dir="$base_dir/build"
result_dir="$build_dir/results"
# Config profile
if [[ -n $2 ]]; then
config=$2
fi
function getDockerVersion() {
local docker_version='local'
if [[ $DOCKER_VERSION != '' ]]; then
docker_version=$DOCKER_VERSION
fi
echo "$docker_version"
}
function fetchSubComponent() {
git -C "$base_dir" submodule update --init --recursive
}
function clean() {
fetchSubComponent
rm -rf "$build_dir"
}
function compile() {
clean
dotnet build "$base_dir/json-ld.net/JsonLD.sln" -c "$config" --nologo
dotnet build "$base_dir/SimpleIdServer.IdServer.Host.sln" -c "$config" --nologo
dotnet build "$base_dir/SimpleIdServer.Scim.Host.sln" -c "$config" --nologo
dotnet build "$base_dir/SimpleIdServer.Did.sln" -c "$config" --nologo
dotnet build "$base_dir/SimpleIdServer.CredentialIssuer.Host.sln" -c "$config" --nologo
}
function setDockerTag() {
local docker_version
docker_version=$(getDockerVersion)
export TAG=$docker_version
}
function dockerBuild {
clean
setDockerTag
echo "Building Docker images with version: $TAG"
dotnet publish "$source_dir/IdServer/SimpleIdServer.IdServer.Startup/SimpleIdServer.IdServer.Startup.csproj" -c "$config" -o "$result_dir/docker/IdServer" --nologo
dotnet publish "$source_dir/IdServer/SimpleIdServer.IdServer.Website.Startup/SimpleIdServer.IdServer.Website.Startup.csproj" -c "$config" -o "$result_dir/docker/IdServerWebsite" --nologo
dotnet publish "$source_dir/Scim/SimpleIdServer.Scim.Startup/SimpleIdServer.Scim.Startup.csproj" -c "$config" -o "$result_dir/docker/Scim" --nologo
dotnet publish "$source_dir/CredentialIssuer/SimpleIdServer.CredentialIssuer.Startup/SimpleIdServer.CredentialIssuer.Startup.csproj" -c "$config" -o "$result_dir/docker/CredentialIssuer" --nologo
dotnet publish "$source_dir/CredentialIssuer/SimpleIdServer.CredentialIssuer.Website.Startup/SimpleIdServer.CredentialIssuer.Website.Startup.csproj" -c "$config" -o "$result_dir/docker/CredentialIssuerWebsite" --nologo
docker compose -f "$base_dir/local-docker-compose.yml" build --no-cache
}
function dockerUp() {
setDockerTag
echo "Running Docker containers with version: $TAG"
docker compose -f "$base_dir/local-docker-compose.yml" up -d
}
function dockerDown() {
echo "Deleting Docker containers"
docker compose -f "$base_dir/local-docker-compose.yml" down
}
function dockerStart() {
echo "Starting Docker containers"
docker compose -f "$base_dir/local-docker-compose.yml" start
}
function dockerStop() {
echo "Stopping Docker containers"
docker compose -f "$base_dir/local-docker-compose.yml" stop
}
function help() {
echo "Use:
. idserver.sh OPTION CONFIG
If alias idserver was added in ~/.bash_aliases file:
idserver OPTION CONFIG
OPTIONs:
clean Clean the folders.
compile Compile all the projects.
dockerBuild Build all the projects for running them in Docker Containers.
dockerUp Build all the projects and run them in Docker Containers.
dockerDown Delete all Docker Containers.
dockerStart Start all Docker Containers.
dockerStop Stop all Docker Containers.
help Show this help message.
CONFIGs:
Possible values are: debug and release"
}
# Calling options
case $1 in
"clean")
clean
echo "All cleaned"
;;
"compile")
compile
echo "All compiled"
;;
"dockerBuild")
dockerBuild
echo "Docker images builded"
;;
"dockerUp")
dockerUp
echo "Docker containers running"
;;
"dockerDown")
dockerDown
echo "Docker containers deleted"
;;
"dockerStart")
dockerStart
echo "Docker containers started"
;;
"dockerStop")
dockerStop
echo "Docker containers stopped"
;;
"fetchSubComponent")
fetchSubComponent
echo "Submodules updated"
;;
*)
help
;;
esac