FROM ubuntu:24.04

# Avoid interactive prompts during apt installs
ENV DEBIAN_FRONTEND=noninteractive

# libvoikko: the Finnish morphology library Tampio depends on
# voikko-fi: provides only mor-standard; fi-x-morpho must be downloaded separately
RUN apt-get update && apt-get install -y \
    libvoikko-dev \
    voikko-fi \
    python3 \
    python3-libvoikko \
    git \
    curl \
    unzip \
    && rm -rf /var/lib/apt/lists/*

# Install the fi-x-morpho dictionary that Tampio requires.
# The voikko-fi apt package only ships mor-standard; the morpho variant is a
# separate snapshot published by the voikko-fi project. The zip unpacks to
# 5/mor-morpho/ which is exactly where libvoikko looks for it under a search
# path. We install it system-wide under /usr/lib/voikko so it is available to
# all users (including non-interactive Docker runs).
RUN curl -fsSL https://www.puimula.org/htp/testing/voikko-snapshot-v5/dict-morpho.zip \
        -o /tmp/dict-morpho.zip \
    && unzip /tmp/dict-morpho.zip -d /usr/lib/voikko \
    && rm /tmp/dict-morpho.zip

# Install Tampio directly from source (not on PyPI or npm)
RUN git clone https://github.com/fergusq/tampio.git /opt/tampio

# Handy wrapper so you can just call `tampio` from anywhere
RUN echo '#!/bin/sh\npython3 /opt/tampio/tampio.py "$@"' > /usr/local/bin/tampio \
    && chmod +x /usr/local/bin/tampio

WORKDIR /tampiorama

CMD ["/bin/bash"]
