2 Commits

Author SHA1 Message Date
5a53e1a782 replace zip with run script 2025-09-07 15:08:12 -07:00
b0e430e19d update command 2025-09-07 04:28:29 -07:00
3 changed files with 36 additions and 8 deletions

View File

@@ -1,12 +1,25 @@
FROM python:3.12-slim FROM python:3.12-slim
# Install dependencies + locales
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
libgl1 \ libgl1 \
libglib2.0-0 \ libglib2.0-0 \
zip \ p7zip-full \
locales \
fonts-noto-cjk \
&& rm -rf /var/lib/apt/lists/* && 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 RUN pip install --no-cache-dir --upgrade torch torchvision mokuro
# create a user to run the application # create a user to run the application
@@ -16,4 +29,6 @@ RUN useradd -m mokurouser \
WORKDIR /mokuro WORKDIR /mokuro
USER mokurouser
COPY . . COPY . .

View File

@@ -1,7 +1,7 @@
--- ---
services: services:
mokuro: mokuro:
image: gitea.suda.codes/sudacode/mokuro-docker:latest image: mokuro
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile

25
run.sh
View File

@@ -1,22 +1,35 @@
#!/usr/bin/env sh #!/usr/bin/env bash
set -Eeuo pipefail 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:-.}" DIR="${1:-.}"
mokuro --parent_dir "$DIR" --disable_confirmation 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 cd "$DIR" || exit
for f in *.mokuro; do for f in *.mokuro; do
[ -e "$f" ] || continue # skip if no .mokuro files [[ -e "$f" ]] || continue
base="${f%.mokuro}" base="${f%.mokuro}"
dir="$base" dir="$base"
zipfile="$base.zip" zipfile="$base.zip"
if [ -f "$zipfile" ]; then if [[ -f "$zipfile" ]]; then
echo "Warning: Zip file $zipfile already exists, skipping." echo "Warning: Zip file $zipfile already exists, skipping."
elif [ -d "$dir" ]; then elif [[ -d "$dir" ]]; then
echo "Zipping: $zipfile <- $f $dir/" echo "Zipping: $zipfile <- $f $dir/"
zip -qr "$zipfile" "$f" "$dir" 7z a -tzip "$zipfile" "$f" "$dir"
else else
echo "Warning: Directory '$dir' not found for '$f', skipping." echo "Warning: Directory '$dir' not found for '$f', skipping."
fi fi