Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Merged Dockerfiles (#282)

Kizaingd00cf7de92cb
diff --git a/Dockerfile b/Dockerfile
index 7f4e8ac71..62dfe4336 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,35 +1,27 @@
-#This Dockerfile pulls the latest git commit and builds Kavita from source
-FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS builder
+#This Dockerfile creates a build for all architectures
-MAINTAINER Chris P
+#Production image
+FROM ubuntu:focal AS copytask
-ENV DEBIAN_FRONTEND=noninteractive
ARG TARGETPLATFORM
-#Installs nodejs and npm
-RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
- && apt-get install -y nodejs \
- && rm -rf /var/lib/apt/lists/*
-
-#Builds app based on platform
-COPY build_target.sh /build_target.sh
-RUN /build_target.sh
+#Move the output files to where they need to be
+RUN mkdir /files
+COPY _output/*.tar.gz /files/
+COPY copy_runtime.sh /copy_runtime.sh
+RUN /copy_runtime.sh
-#Production image
FROM ubuntu:focal
-MAINTAINER Chris P
-
-#Move the output files to where they need to be
-COPY --from=builder /Projects/Kavita/_output/build/Kavita /kavita
+COPY --from=copytask /kavita /kavita
#Installs program dependencies
RUN apt-get update \
&& apt-get install -y libicu-dev libssl1.1 pwgen \
&& rm -rf /var/lib/apt/lists/*
-#Creates the manga storage directory
-RUN mkdir /manga /kavita/data
+#Creates the data directory
+RUN mkdir /kavita/data
RUN cp /kavita/appsettings.Development.json /kavita/appsettings.json \
&& sed -i 's/Data source=kavita.db/Data source=data\/kavita.db/g' /kavita/appsettings.json
diff --git a/Dockerfile.alpine b/Dockerfile.alpine
deleted file mode 100644
index faacfa823..000000000
--- a/Dockerfile.alpine
+++ /dev/null
@@ -1,28 +0,0 @@
-#This Dockerfile is for the musl alpine build of Kavita.
-FROM alpine:latest
-
-MAINTAINER Chris P
-
-#Installs the needed dependencies
-RUN apk update && apk add --no-cache wget curl pwgen icu-dev bash
-
-#Downloads Kavita, unzips and moves the folders to where they need to be
-RUN wget https://github.com/Kareadita/Kavita/releases/download/v0.3.7/kavita-linux-musl-x64.tar.gz \
- && tar -xzf kavita*.tar.gz \
- && mv Kavita/ /kavita/ \
- && rm kavita*.gz \
- && chmod +x /kavita/Kavita
-
-#Creates the needed folders
-RUN mkdir /manga /kavita/data /kavita/temp /kavita/cache
-
-RUN sed -i 's/Data source=kavita.db/Data source=data\/kavita.db/g' /kavita/appsettings.json
-
-COPY entrypoint.sh /entrypoint.sh
-
-EXPOSE 5000
-
-WORKDIR /kavita
-
-ENTRYPOINT ["/bin/bash"]
-CMD ["/entrypoint.sh"]
diff --git a/Dockerfile.arm b/Dockerfile.arm
deleted file mode 100644
index e28430a38..000000000
--- a/Dockerfile.arm
+++ /dev/null
@@ -1,27 +0,0 @@
-#This Dockerfile pulls the latest git commit and builds Kavita from source
-
-#Production image
-FROM ubuntu:focal
-
-#Move the output files to where they need to be
-COPY Kavita /kavita
-
-#Installs program dependencies
-RUN apt-get update \
- && apt-get install -y libicu-dev libssl1.1 pwgen \
- && rm -rf /var/lib/apt/lists/*
-
-#Creates the manga storage directory
-RUN mkdir /kavita/data
-
-RUN cp /kavita/appsettings.Development.json /kavita/appsettings.json \
- && sed -i 's/Data source=kavita.db/Data source=data\/kavita.db/g' /kavita/appsettings.json
-
-COPY entrypoint.sh /entrypoint.sh
-
-EXPOSE 5000
-
-WORKDIR /kavita
-
-ENTRYPOINT ["/bin/bash"]
-CMD ["/entrypoint.sh"]
diff --git a/build_target.sh b/build_target.sh
deleted file mode 100644
index 56c54ba79..000000000
--- a/build_target.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-mkdir Projects
-
-cd Projects
-
-git clone https://github.com/Kareadita/Kavita.git
-git clone https://github.com/Kareadita/Kavita-webui.git
-
-cd Kavita
-chmod +x build.sh
-
-#Builds program based on the target platform
-
-if [ "$TARGETPLATFORM" == "linux/amd64" ]
-then
- ./build.sh linux-x64
- mv /Projects/Kavita/_output/linux-x64 /Projects/Kavita/_output/build
-elif [ "$TARGETPLATFORM" == "linux/arm/v7" ]
-then
- ./build.sh linux-arm
- mv /Projects/Kavita/_output/linux-arm /Projects/Kavita/_output/build
-elif [ "$TARGETPLATFORM" == "linux/arm64" ]
-then
- ./build.sh linux-arm64
- mv /Projects/Kavita/_output/linux-arm64 /Projects/Kavita/_output/build
-fi
diff --git a/copy_runtime.sh b/copy_runtime.sh
new file mode 100644
index 000000000..f46a720f1
--- /dev/null
+++ b/copy_runtime.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+#Copies the correct version of Kavita into the image
+
+set -xv
+
+if [ "$TARGETPLATFORM" == "linux/amd64" ]
+then
+ tar xf /files/kavita-linux-x64.tar.gz -C /
+ mv /Kavita /kavita
+elif [ "$TARGETPLATFORM" == "linux/arm/v7" ]
+then
+ tar xf /files/kavita-linux-arm.tar.gz -C /
+ mv /Kavita /kavita
+elif [ "$TARGETPLATFORM" == "linux/arm64" ]
+then
+ tar xf /files/kavita-linux-arm64.tar.gz -C /
+ mv /Kavita /kavita
+fi
diff --git a/docker-build.sh b/docker-build.sh
new file mode 100644
index 000000000..05b05dda4
--- /dev/null
+++ b/docker-build.sh
@@ -0,0 +1,98 @@
+#! /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 Debug
+ 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'
+ cd ../Kavita-webui/ || exit
+ npm install
+ npm run prod
+ cd ../Kavita/ || exit
+ ProgressEnd 'Building UI'
+}
+
+Package()
+{
+ local framework="$1"
+ local runtime="$2"
+ local lOutputFolder=../_output/"$runtime"/Kavita
+
+ ProgressStart "Creating $runtime Package for $framework"
+
+ # 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" --framework $framework
+ dotnet publish -c Release --no-restore --self-contained --runtime $runtime -o "$lOutputFolder" --framework $framework
+
+ 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 for $framework"
+
+}
+
+dir=$PWD
+
+if [ -d _output ]
+then
+ rm -r _output/
+fi
+
+BuildUI
+
+#Build for x64
+Build "linux-x64"
+Package "net5.0" "linux-x64"
+cd "$dir"
+
+#Build for arm
+Build "linux-arm"
+Package "net5.0" "linux-arm"
+cd "$dir"
+
+#Build for arm64
+Build "linux-arm64"
+Package "net5.0" "linux-arm64"
+cd "$dir"
+
+#Builds Docker images
+docker buildx build -t kizaing/kavita:nightly --platform linux/amd64,linux/arm/v7,linux/arm64 . --push
\ No newline at end of file