From 5a53e1a7829828f595c31d86ff53e9e8bdcb5231 Mon Sep 17 00:00:00 2001 From: sudacode Date: Sun, 7 Sep 2025 15:08:12 -0700 Subject: [PATCH] replace zip with run script --- Dockerfile | 17 ++++++++++++++++- compose.yaml | 4 ++-- run.sh | 38 ++++++++++++++++++++++++++++++++++++++ zip.sh | 24 ------------------------ 4 files changed, 56 insertions(+), 27 deletions(-) create mode 100755 run.sh delete mode 100755 zip.sh diff --git a/Dockerfile b/Dockerfile index d8776af..630af52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,25 @@ FROM python:3.12-slim +# Install dependencies + locales RUN apt-get update \ && apt-get install -y --no-install-recommends \ libgl1 \ libglib2.0-0 \ - zip \ + p7zip-full \ + locales \ + fonts-noto-cjk \ && rm -rf /var/lib/apt/lists/* +# Generate Japanese UTF-8 locale +RUN sed -i '/ja_JP.UTF-8/s/^# //g' /etc/locale.gen \ + && locale-gen + +# Set environment variables for locale +ENV LANG=ja_JP.UTF-8 \ + LANGUAGE=ja_JP:ja \ + LC_ALL=ja_JP.UTF-8 \ + LC_CTYPE=ja_JP.UTF-8 + RUN pip install --no-cache-dir --upgrade torch torchvision mokuro # create a user to run the application @@ -16,4 +29,6 @@ RUN useradd -m mokurouser \ WORKDIR /mokuro +USER mokurouser + COPY . . diff --git a/compose.yaml b/compose.yaml index 6cd5dfa..e8e0133 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,7 @@ --- services: mokuro: - image: gitea.suda.codes/sudacode/mokuro-docker:latest + image: mokuro build: context: . dockerfile: Dockerfile @@ -9,7 +9,7 @@ services: user: 1000:1000 volumes: - ~/S/japanese/manga:/mokuro/manga - command: mokuro --parent_dir "manga/One Piece Color" --disable_confirmation + command: ./run.sh "manga/One Piece Color" runtime: nvidia restart: no network_mode: host diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..2cb3f37 --- /dev/null +++ b/run.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail +export LANG=ja_JP.UTF-8 +export LANGUAGE=ja_JP:ja +export LC_ALL=ja_JP.UTF-8 +export LC_CTYPE=ja_JP.UTF-8 + +DIR="${1:-.}" + +if [[ ! -d "$DIR" ]]; then + echo "Error: Directory '$DIR' does not exist." + exit 1 +fi + +if ! mokuro --parent_dir "$DIR" --disable_confirmation; then + echo "Error: mokuro command failed." + exit 1 +fi + +cd "$DIR" || exit + +for f in *.mokuro; do + [[ -e "$f" ]] || continue + base="${f%.mokuro}" + dir="$base" + zipfile="$base.zip" + if [[ -f "$zipfile" ]]; then + echo "Warning: Zip file $zipfile already exists, skipping." + elif [[ -d "$dir" ]]; then + echo "Zipping: $zipfile <- $f $dir/" + 7z a -tzip "$zipfile" "$f" "$dir" + else + echo "Warning: Directory '$dir' not found for '$f', skipping." + fi +done + +rm -rf ./*.html diff --git a/zip.sh b/zip.sh deleted file mode 100755 index 558ee6c..0000000 --- a/zip.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -Eeuo pipefail - -DIR="${1:-.}" - -cd "$DIR" || exit - -for f in *.mokuro; do - [ -e "$f" ] || continue # skip if no .mokuro files - base="${f%.mokuro}" - dir="$base" - zipfile="$base.zip" - if [ -f "$zipfile" ]; then - echo "Warning: Zip file $zipfile already exists, skipping." - elif [ -d "$dir" ]; then - echo "Zipping: $zipfile <- $f $dir/" - zip -qr "$zipfile" "$f" "$dir" - else - echo "Warning: Directory '$dir' not found for '$f', skipping." - fi -done - -rm -rf ./*.html