Sign inSign up

lukaprimus/languagetool:latest

Languages & frameworks
Integration & delivery
Manifest digest

sha256:ef0b6308f73b8da02daecd1511ff2d584cc35d602219ad9f9ad3d15c82de009b

Last pushed

14 days by lukaprimus

Type

Compose

Manifest digest

sha256:ef0b6308f73b8da02daecd1511ff2d584cc35d602219ad9f9ad3d15c82de009b

Compose file content

name: languagetool

# Exact image used by the original container (LanguageTool 6.8).
x-languagetool-image: &languagetool-image elestio/languagetool@sha256:47bd72901e400849e44d1f4aed351d6f740ee00d4714ff52464e7dd7c441b3e4

services:
  ngrams-download:
    image: alpine:3.20
    user: "0:0"
    restart: "no"
    healthcheck:
      disable: true
    volumes:
      - ngrams:/ngrams
    entrypoint: ["/bin/sh", "-ec"]
    command:
      - |
        apk add --no-cache curl unzip >/dev/null
        umask 022
        for dataset in de-20150819 en-20150817; do
          lang=$${dataset%%-*}
          marker="/ngrams/.$$dataset.complete"
          if [ -f "$$marker" ] &&
             [ -d "/ngrams/$$lang/1grams" ] &&
             [ -d "/ngrams/$$lang/2grams" ] &&
             [ -d "/ngrams/$$lang/3grams" ]; then
            echo "$$lang n-grams already installed; skipping."
            continue
          fi

          archive="/ngrams/ngrams-$$dataset.zip"
          staging="/ngrams/.extract-$$dataset"
          echo "Downloading $$lang n-grams (resuming any partial download)..."
          curl --fail --location --show-error \
            --retry 5 --retry-delay 10 --connect-timeout 30 \
            --speed-limit 1024 --speed-time 120 \
            --continue-at - --output "$$archive" \
            "https://languagetool.org/download/ngram-data/ngrams-$$dataset.zip"

          rm -rf "$$staging"
          mkdir -p "$$staging"
          echo "Extracting $$lang n-grams..."
          if ! unzip -tq "$$archive" >/dev/null; then
            echo "Archive validation failed. Removing corrupt archive so the next run starts cleanly." >&2
            rm -f "$$archive"
            exit 1
          fi
          if ! unzip -q -o "$$archive" -d "$$staging"; then
            echo "Extraction failed. Removing corrupt archive; check free disk space before retrying." >&2
            rm -f "$$archive"
            exit 1
          fi
          for order in 1 2 3; do
            test -d "$$staging/$$lang/$${order}grams"
          done
          chmod -R a+rX "$$staging/$$lang"
          rm -rf "/ngrams/$$lang"
          mv "$$staging/$$lang" "/ngrams/$$lang"
          touch "$$marker"
          rm -rf "$$staging"
          rm -f "$$archive"
          echo "$$lang n-grams installed."
        done

  languagetool:
    image: *languagetool-image
    restart: unless-stopped
    ports:
      - "8081:8010"
    environment:
      langtool_languageModel: /ngrams
      # German initialization exceeded the image's default 512 MB heap.
      Java_Xmx: 2g
    volumes:
      - ngrams:/ngrams:ro
    depends_on:
      ngrams-download:
        condition: service_completed_successfully
    # The image supplies the startup command and health check.

volumes:
  ngrams:

Docker commands

docker compose -f oci://lukaprimus/languagetool:latest up

Use the above command to pull and run the Compose file. Learn more⁠.

Images used

Image

A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size!


Pulls

1B+

Stars

11579

Last Updated

9 days