diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 00000000..c3c2567b --- /dev/null +++ b/Dockerfile.local @@ -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"] \ No newline at end of file diff --git a/Dockerfile.simple b/Dockerfile.simple new file mode 100644 index 00000000..0a5157bd --- /dev/null +++ b/Dockerfile.simple @@ -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"] \ No newline at end of file diff --git a/Dockerfile.simple-local b/Dockerfile.simple-local new file mode 100644 index 00000000..0b26a7fb --- /dev/null +++ b/Dockerfile.simple-local @@ -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"] \ No newline at end of file diff --git a/build-local-docker.sh b/build-local-docker.sh new file mode 100755 index 00000000..b6311841 --- /dev/null +++ b/build-local-docker.sh @@ -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" \ No newline at end of file diff --git a/build-simple-docker.sh b/build-simple-docker.sh new file mode 100755 index 00000000..e7ee87c8 --- /dev/null +++ b/build-simple-docker.sh @@ -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)" \ No newline at end of file