From 7750b593f6b301d874261cf5e5bd8aafa0d013d2 Mon Sep 17 00:00:00 2001 From: "duong.doan1" Date: Tue, 7 Apr 2026 18:29:00 +0700 Subject: [PATCH] refactor: simplify Docker build setup - Remove all simple Docker files (Dockerfile.simple, Dockerfile.simple-local, build-simple-docker.sh) - Remove docker-compose.local.yml - Update docker-compose.yml to use Dockerfile.local for builds - Update build-local-docker.sh as the single build script - Keep only multi-stage Dockerfile.local for comprehensive local builds --- Dockerfile.simple | 14 -------------- Dockerfile.simple-local | 14 -------------- build-local-docker.sh | 13 ++++++++----- build-simple-docker.sh | 31 ------------------------------- docker-compose-test.yml | 7 ++----- docker-compose.local.yml | 2 +- docker/postgres/init.sql | 10 +++++++++- 7 files changed, 20 insertions(+), 71 deletions(-) delete mode 100644 Dockerfile.simple delete mode 100644 Dockerfile.simple-local delete mode 100755 build-simple-docker.sh diff --git a/Dockerfile.simple b/Dockerfile.simple deleted file mode 100644 index 0a5157bd..00000000 --- a/Dockerfile.simple +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 0b26a7fb..00000000 --- a/Dockerfile.simple-local +++ /dev/null @@ -1,14 +0,0 @@ -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 index b6311841..d0fbea91 100755 --- a/build-local-docker.sh +++ b/build-local-docker.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Build local Docker image for Komga +# Build Komga Docker image locally with multi-stage build set -e echo "Building Komga Docker image locally..." @@ -9,17 +9,20 @@ echo "Building Komga Docker image locally..." VERSION=$(grep 'version=' gradle.properties | cut -d'=' -f2) echo "Building version: $VERSION" -# Build Docker image with Node.js 18 support +# Build Docker image with multi-stage build (Node.js 18 + Java 21) 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 " Build: Multi-stage (Node.js 18 + Java 21)" +echo " Runtime: Java 21 (Temurin JRE)" echo "" -echo "To run the container:" +echo "To run standalone container:" echo " docker run -p 25600:25600 -v /path/to/config:/config komga-local:$VERSION" echo "" +echo "To run with docker-compose:" +echo " docker-compose up -d" +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 deleted file mode 100755 index e7ee87c8..00000000 --- a/build-simple-docker.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/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 diff --git a/docker-compose-test.yml b/docker-compose-test.yml index e687a602..4cf35cbd 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -2,7 +2,7 @@ version: '3.8' services: postgres-test: - image: postgres:16-alpine + image: postgres:15-alpine container_name: komga-postgres-test environment: POSTGRES_DB: komga_test @@ -21,9 +21,7 @@ services: command: ["postgres", "-c", "log_statement=all"] # Log all SQL for debugging komga-test: - build: - context: . - dockerfile: docker/Dockerfile + image: gotson/komga:latest container_name: komga-test-backend depends_on: postgres-test: @@ -39,7 +37,6 @@ services: - "25601:25600" volumes: - ./data:/data:ro - command: ["./gradlew", ":komga:bootRun", "--args='--spring.profiles.active=test'"] restart: "no" volumes: diff --git a/docker-compose.local.yml b/docker-compose.local.yml index ce96e427..6e354bd0 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -22,7 +22,7 @@ services: komga: build: context: . - dockerfile: Dockerfile.simple-local + dockerfile: Dockerfile.local container_name: komga-backend depends_on: postgres: diff --git a/docker/postgres/init.sql b/docker/postgres/init.sql index 16f9af7e..f487de11 100644 --- a/docker/postgres/init.sql +++ b/docker/postgres/init.sql @@ -4,4 +4,12 @@ -- Enable required extensions CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE EXTENSION IF NOT EXISTS "pg_trgm"; -- For text search/pattern matching -CREATE EXTENSION IF NOT EXISTS "unaccent"; -- For accent removal (similar to UDF_STRIP_ACCENTS) \ No newline at end of file +CREATE EXTENSION IF NOT EXISTS "unaccent"; -- For accent removal (similar to UDF_STRIP_ACCENTS) + +-- Set reasonable default configuration for Komga +ALTER DATABASE komga SET timezone TO 'UTC'; +ALTER DATABASE komga SET default_transaction_isolation TO 'read committed'; +ALTER DATABASE komga SET lock_timeout TO '30s'; +ALTER DATABASE komga SET statement_timeout TO '60000'; + +-- Create schema if needed (public schema is default) \ No newline at end of file