mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Merged Dockerfiles (#282)
* Dockerfile re-imagined to handle all flavors in one script.
This commit is contained in:
parent
41a5d1bf2c
commit
d00cf7de92
34
Dockerfile
34
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
|
||||
|
||||
MAINTAINER Chris P
|
||||
|
||||
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
|
||||
#This Dockerfile creates a build for all architectures
|
||||
|
||||
#Production image
|
||||
FROM ubuntu:focal
|
||||
FROM ubuntu:focal AS copytask
|
||||
|
||||
MAINTAINER Chris P
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
#Move the output files to where they need to be
|
||||
COPY --from=builder /Projects/Kavita/_output/build/Kavita /kavita
|
||||
RUN mkdir /files
|
||||
COPY _output/*.tar.gz /files/
|
||||
COPY copy_runtime.sh /copy_runtime.sh
|
||||
RUN /copy_runtime.sh
|
||||
|
||||
FROM ubuntu:focal
|
||||
|
||||
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
|
||||
|
@ -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"]
|
@ -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"]
|
@ -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
|
19
copy_runtime.sh
Normal file
19
copy_runtime.sh
Normal file
@ -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
|
98
docker-build.sh
Normal file
98
docker-build.sh
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user