mirror of
https://github.com/gotson/komga.git
synced 2026-05-08 12:35:30 +02:00
feat: add local Docker build scripts and configurations
- Add Dockerfile.local for multi-stage build with Node.js 18 - Add Dockerfile.simple-local for simple JAR-based builds - Add build-local-docker.sh script for comprehensive local builds - Add build-simple-docker.sh script for quick JAR-based builds - Support building Komga images locally without pushing to registries
This commit is contained in:
parent
5929233ff7
commit
d430c99f43
5 changed files with 130 additions and 0 deletions
46
Dockerfile.local
Normal file
46
Dockerfile.local
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
FROM node:18-alpine AS node-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy frontend source
|
||||
COPY komga-webui/package.json komga-webui/package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY komga-webui/ ./
|
||||
RUN npm run build
|
||||
|
||||
FROM eclipse-temurin:21-jdk-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy gradle files
|
||||
COPY gradle ./gradle
|
||||
COPY gradlew ./
|
||||
COPY gradle.properties ./
|
||||
COPY settings.gradle ./
|
||||
COPY build.gradle.kts ./
|
||||
|
||||
# Copy source code
|
||||
COPY komga ./komga
|
||||
|
||||
# Copy built frontend from node-builder
|
||||
COPY --from=node-builder /app/dist komga-webui/dist
|
||||
|
||||
# Build the application including frontend
|
||||
RUN ./gradlew prepareThymeLeaf bootJar -x test
|
||||
|
||||
# Runtime stage
|
||||
FROM eclipse-temurin:21-jre-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy built artifact from build stage
|
||||
COPY --from=build /app/komga/build/libs/komga-*.jar komga.jar
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -S komga && adduser -S komga -G komga
|
||||
USER komga
|
||||
|
||||
EXPOSE 25600
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "komga.jar"]
|
||||
14
Dockerfile.simple
Normal file
14
Dockerfile.simple
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
FROM eclipse-temurin:21-jre-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built JAR file (assuming it's built locally)
|
||||
COPY komga/build/libs/komga-*.jar komga.jar
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -S komga && adduser -S komga -G komga
|
||||
USER komga
|
||||
|
||||
EXPOSE 25600
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "komga.jar"]
|
||||
14
Dockerfile.simple-local
Normal file
14
Dockerfile.simple-local
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
FROM eclipse-temurin:21-jre-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built JAR file (assume it's built locally first)
|
||||
COPY komga/build/libs/komga-*.jar komga.jar
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -S komga && adduser -S komga -G komga
|
||||
USER komga
|
||||
|
||||
EXPOSE 25600
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "komga.jar"]
|
||||
25
build-local-docker.sh
Executable file
25
build-local-docker.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Build local Docker image for Komga
|
||||
set -e
|
||||
|
||||
echo "Building Komga Docker image locally..."
|
||||
|
||||
# Get version from gradle.properties
|
||||
VERSION=$(grep 'version=' gradle.properties | cut -d'=' -f2)
|
||||
echo "Building version: $VERSION"
|
||||
|
||||
# Build Docker image with Node.js 18 support
|
||||
docker build -f Dockerfile.local -t komga-local:$VERSION .
|
||||
|
||||
echo ""
|
||||
echo "Docker image built successfully:"
|
||||
echo " Image: komga-local:$VERSION"
|
||||
echo " Node.js: 18.20.4 (from Alpine 3.18 repository)"
|
||||
echo " Java: 21 (Temurin)"
|
||||
echo ""
|
||||
echo "To run the container:"
|
||||
echo " docker run -p 25600:25600 -v /path/to/config:/config komga-local:$VERSION"
|
||||
echo ""
|
||||
echo "To tag with different name:"
|
||||
echo " docker tag komga-local:$VERSION komga:latest"
|
||||
31
build-simple-docker.sh
Executable file
31
build-simple-docker.sh
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Build Komga locally and create Docker image
|
||||
set -e
|
||||
|
||||
echo "Building Komga Docker image from existing JAR..."
|
||||
|
||||
# Get version from gradle.properties
|
||||
VERSION=$(grep 'version=' gradle.properties | cut -d'=' -f2)
|
||||
echo "Building Docker image for version: $VERSION"
|
||||
|
||||
# Check if JAR exists
|
||||
if [ ! -f "komga/build/libs/komga-$VERSION.jar" ]; then
|
||||
echo "Error: JAR file not found. Run './gradlew bootJar' first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build Docker image
|
||||
docker build -f Dockerfile.simple-local -t komga-local:$VERSION .
|
||||
|
||||
echo ""
|
||||
echo "Docker image built successfully:"
|
||||
echo " Image: komga-local:$VERSION"
|
||||
echo " Size: $(docker images --format "{{.Size}}" komga-local:$VERSION)"
|
||||
echo " Java: 21 (Temurin JRE)"
|
||||
echo " Entrypoint: java -jar komga.jar"
|
||||
echo ""
|
||||
echo "To run the container:"
|
||||
echo " docker run -p 25600:25600 -v /path/to/config:/config komga-local:$VERSION"
|
||||
echo ""
|
||||
echo "Note: Assumes frontend was already built (via prepareThymeLeaf)"
|
||||
Loading…
Reference in a new issue