-
Notifications
You must be signed in to change notification settings - Fork 28
/
docker-build.sh
executable file
·51 lines (43 loc) · 1.32 KB
/
docker-build.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
#!/bin/bash
set -euo pipefail
if [[ "$#" == "0" ]] || [[ "$#" > "1" ]] || ! [[ "$1" =~ ^(all|x64|arm|arm64|win64)$ ]] ; then
echo "Usage: docker-build.sh {all|x64|arm|arm64|win64}"
exit 1
fi
DIR=$(dirname "$(realpath $0)")
cd "$DIR"
declare -A archs=(
["x64"]="linux-x64"
["arm"]="linux-arm"
["arm64"]="linux-arm64"
["win64"]="win-x64"
)
for sub in "${!archs[@]}" ; do
arch="${archs[$sub]}"
if [[ "$1" != "all" ]] && [[ "$1" != "$sub" ]] ; then
continue
fi
docker run \
-u `id -u`:`id -g` \
-v "/$DIR/"://app/ \
-w //app/ \
-e DOTNET_CLI_HOME=//app/cache/ \
-e XDG_DATA_HOME=//app/cache/ \
mcr.microsoft.com/dotnet/sdk:6.0 \
dotnet publish \
./Server/Server.csproj \
-r $arch \
-c Release \
-o /app/bin/$sub/ \
--self-contained \
-p:publishSingleFile=true \
;
filename="Server"
ext=""
if [[ "$sub" == "arm" ]] ; then filename="Server.arm";
elif [[ "$sub" == "arm64" ]] ; then filename="Server.arm64";
elif [[ "$sub" == "win64" ]] ; then filename="Server.exe"; ext=".exe";
fi
mv ./bin/$sub/Server$ext ./bin/$filename
rm -rf ./bin/$sub/
done