FROM ubuntu:22.04

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        libgmp10 \
        socat \
    && rm -rf /var/lib/apt/lists/*

ARG SIMPLEX_CHAT_VERSION
ARG TARGETARCH

RUN case "$TARGETARCH" in \
        amd64) simplex_arch=x86_64 ;; \
        arm64) simplex_arch=aarch64 ;; \
        *) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
    esac \
    && curl -fsSL \
        "https://github.com/simplex-chat/simplex-chat/releases/download/${SIMPLEX_CHAT_VERSION}/simplex-chat-ubuntu-22_04-${simplex_arch}" \
        -o /tmp/simplex-chat \
    && install -m 755 /tmp/simplex-chat /usr/local/bin/simplex-chat \
    && rm /tmp/simplex-chat

COPY --chmod=755 entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bot_avatar.jpeg /simplex/bot_avatar.jpeg

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
