-
-
Notifications
You must be signed in to change notification settings - Fork 353
/
docker-build.sh
executable file
·103 lines (77 loc) · 2 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
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
#! /bin/bash
set -e
outputFolder='_output'
ProgressStart()
{
echo "Start '$1'"
}
ProgressEnd()
{
echo "Finish '$1'"
}
Build()
{
local RID="$1"
ProgressStart "Build for $RID"
slnFile=Kavita.sln
dotnet clean $slnFile -c Release
dotnet msbuild -restore $slnFile -p:Configuration=Release -p:Platform="Any CPU" -p:RuntimeIdentifiers=$RID
ProgressEnd "Build for $RID"
}
BuildUI()
{
ProgressStart 'Building UI'
echo 'Removing old wwwroot'
rm -rf API/wwwroot/*
cd UI/Web/ || exit
echo 'Installing web dependencies'
npm install --legacy-peer-deps
echo 'Building UI'
npm run prod
echo 'Copying back to Kavita wwwroot'
mkdir -p ../../API/wwwroot
cp -R dist/browser/* ../../API/wwwroot
cd ../../ || exit
ProgressEnd 'Building UI'
}
Package()
{
local runtime="$1"
local lOutputFolder=../_output/"$runtime"/Kavita
ProgressStart "Creating $runtime Package"
# TODO: Use no-restore? Because Build should have already done it for us
echo "Building"
cd API
echo dotnet publish -c Release --no-restore --self-contained --runtime $runtime -o "$lOutputFolder"
dotnet publish -c Release --no-restore --self-contained --runtime $runtime -o "$lOutputFolder"
echo "Copying Install information"
cp ../INSTALL.txt "$lOutputFolder"/README.txt
echo "Copying LICENSE"
cp ../LICENSE "$lOutputFolder"/LICENSE.txt
echo "Renaming API -> Kavita"
mv "$lOutputFolder"/API "$lOutputFolder"/Kavita
echo "Creating tar"
cd ../$outputFolder/"$runtime"/
tar -czvf ../kavita-$runtime.tar.gz Kavita
ProgressEnd "Creating $runtime Package"
}
dir=$PWD
if [ -d _output ]
then
rm -r _output/
fi
BuildUI
#Build for x64
Build "linux-x64"
Package "linux-x64"
cd "$dir"
#Build for arm
Build "linux-arm"
Package "linux-arm"
cd "$dir"
#Build for arm64
Build "linux-arm64"
Package "linux-arm64"
cd "$dir"
#Builds Docker images
docker buildx build -t kizaing/kavita:nightly --platform linux/amd64,linux/arm/v7,linux/arm64 . --push