# dockerfiles/Dockerfile.monero-wallet-rpc
# syntax=docker/dockerfile:1.6
ARG DEBIAN_IMAGE=debian:bookworm-slim
ARG MONERO_VERSION=v0.18.4.1

FROM ${DEBIAN_IMAGE}
ARG TARGETARCH
ARG MONERO_VERSION

RUN set -eux; \
    apt-get update; \
    apt-get install -y --no-install-recommends ca-certificates curl bzip2; \
    update-ca-certificates; \
    rm -rf /var/lib/apt/lists/*

RUN set -eux; \
    case "${TARGETARCH:-arm64}" in \
      amd64)  F="monero-linux-x64"   ;; \
      arm64)  F="monero-linux-armv8" ;; \
      arm)    F="monero-linux-armv7" ;; \
      *) echo "Unsupported TARGETARCH=${TARGETARCH}"; exit 1 ;; \
    esac; \
    URL="https://downloads.getmonero.org/cli/${F}-${MONERO_VERSION}.tar.bz2"; \
    echo "Fetching $URL"; \
    mkdir -p /opt/monero; \
    curl -fsSL "$URL" -o /opt/monero/monero.tar.bz2; \
    tar -xjf /opt/monero/monero.tar.bz2 -C /opt/monero --strip-components=1; \
    install -m 0755 /opt/monero/monero-wallet-rpc /usr/local/bin/monero-wallet-rpc; \
    rm -f /opt/monero/monero.tar.bz2; \
    groupadd --system monero; \
    useradd --system --uid 1000 --gid monero --home-dir /nonexistent --shell /usr/sbin/nologin monero

ENV PATH="/usr/local/bin:/usr/bin:/bin"
RUN /usr/local/bin/monero-wallet-rpc --version || true

EXPOSE 18083
USER monero
