xmrsale / xmrSale

Lightweight Monero payment processor written in easily deployable Python. Self custody donations and payments, directly connected to your own Bitcoin node! No middleman/custodian.
MIT License
24 stars 6 forks source link

Replace start.sh shell script and altered monerod image with standalone monero-wallet-rpc Dockerfile #1

Open CryptoGrampy opened 2 years ago

CryptoGrampy commented 2 years ago

https://github.com/xmrsale/xmrSale/blob/5869768ca5f9a0bd1fb1e3d4cc1781a5d98e582e/xmrnode/start.sh#L1

This may already be on your to-do list, but I would highly recommend replacing the edits to Seth's simple-monerod Dockerfile + having to deal with this start.sh script business with simply creating a new Dockerfile and service called monero-wallet-rpc that basically tears out the monerod stuff from Seth's simple-monerod image and replaces it with the monerod-wallet-rpc stuff (you've basically already done this part, just remove the monerod stuff). You could even publish this to Dockerhub.

The end user then has 3 separate images to deal with and configure:

  1. monerod image(user could just pull Seth's image here)
  2. monero-wallet-rpc image(add nothing in here that is xmrSale-specific. User can build the monero-wallet-rpc Dockerfile or pull from dockerhub if you publish it)
  3. xmrsale image

Someone who already has a node running, they then only need to add the monero-wallet-rpc service/pull the image and pipe in the connection info for the running node and configuration into the wallet service. It will make it much more pleasant to test this system out as well :-)

And yes, you basically have all of the hard work already done

CryptoGrampy commented 2 years ago

Roughly, something like this (didn't test, would be nice to expose the password and daemon address commands, perhaps) :

monero-wallet-rpc/Dockerfile:

# From https://github.com/leonardochaia/docker-monerod/blob/master/src/Dockerfile
# and https://github.com/sethforprivacy/simple-monerod-docker/blob/main/Dockerfile

ARG MONERO_BRANCH=v0.17.2.3

# Select Ubuntu 20.04LTS for the build image base
FROM ubuntu:20.04 as build
LABEL author="xmsale@protonmail.com" \
      maintainer="xmsale@protonmail.com"

# Dependency list from https://github.com/monero-project/monero#compiling-monero-from-source
# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation
RUN apt-get update \
    && apt-get upgrade -y \
    && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends build-essential cmake \
    pkg-config libboost-all-dev libssl-dev libzmq3-dev libunbound-dev ca-certificates \
    libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev \
    libexpat1-dev doxygen graphviz libpgm-dev qttools5-dev-tools libhidapi-dev \
    libusb-dev libprotobuf-dev protobuf-compiler libgtest-dev git \
    libnorm-dev libpgm-dev libusb-1.0-0-dev libudev-dev libgssapi-krb5-2 \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

ENV CFLAGS='-fPIC'
ENV CXXFLAGS='-fPIC'
ENV USE_SINGLE_BUILDDIR 1
ENV BOOST_DEBUG         1

# Switch to directory for gtest and make/install libs
WORKDIR /usr/src/gtest
RUN cmake . \
    && make \
    && cp ./lib/libgtest*.a /usr/lib

# Switch to Monero source directory
WORKDIR /monero

# Git pull Monero source at specified tag/branch
ARG MONERO_BRANCH
RUN git clone --recursive --branch ${MONERO_BRANCH} \
    https://github.com/monero-project/monero . \
    && git submodule init && git submodule update

# Make static Monero binaries
ARG NPROC
RUN test -z "$NPROC" && nproc > /nproc || echo -n "$NPROC" > /nproc && make -j"$(cat /nproc)" release-static

# Select Ubuntu 20.04LTS for the image base
FROM ubuntu:20.04

# Install remaining dependencies
RUN apt-get update \
    && apt-get upgrade -y \
    && apt-get install --no-install-recommends -y curl libnorm-dev libpgm-dev libgssapi-krb5-2 \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Add user and setup directories for monero-wallet-rpc
RUN useradd -ms /bin/bash monero \
    && mkdir -p /home/monero/.bitmonero/wallet/ \
    && chown -R monero:monero /home/monero/.bitmonero/wallet/
USER monero

# Switch to home directory and install newly built monerod binary
WORKDIR /home/monero
COPY --chown=monero:monero --from=build /monero/build/release/bin/monero-wallet-rpc /usr/local/bin/monero-wallet-rpc

# Add HEALTHCHECK against get_info endpoint
# HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://localhost:18089/get_info || exit 1

ENTRYPOINT ["monero-wallet-rpc", "--non-interactive"]
CMD ["--rpc-bind-ip=0.0.0.0", "--rpc-bind-port=18090", "--wallet-file=/home/monero/.bitmonero/wallet", "--password=''"]

docker-compose.yml:

services:
  monerod:
    image: sethsimmons/simple-monerod:latest
    user: monero
    restart: unless-stopped
    container_name: monerod
    volumes:
      - bitmonero:/home/monero/.bitmonero
    ports:
      - 18080:18080
      - 18089:18089
    command:
      - "--rpc-restricted-bind-ip=0.0.0.0"
      - "--rpc-restricted-bind-port=18089"
      - "--no-igd"
      - "--enable-dns-blocklist"
      - "--prune-blockchain"
  walletrpc:
      build: monero-wallet-rpc/
      ports:
          - 18090:18090
      entrypoint: []
      volumes:
        - bitmonero:/home/monero/.bitmonero
        # /dir/ must contain a wallet and wallet.keys file!
        - ~/wallet:/home/monero/.bitmonero/wallet/
      command:
        - "--password=CHANGEME"
        - "--daemon-address=127.0.0.1:18089"
  xmrsale:
    build: .
    ports:
      - 8000:8000
    environment:
      MONERODRPC_PORT: "18089"
      MONERODRPC_USER: "xmrsale"
      MONERODRPC_PASS: "verylongxmrnodepassword"
      MONEROWALLETRPC_PORT: "18090"
      WALLETRPC_USER: "xmrsale"
      WALLETRPC_PASS: "verylongxmrwalletpassword"

volumes:
  bitmonero:
CryptoGrampy commented 2 years ago

Annnnnnd Seth already created monero-wallet-rpc docker image: https://github.com/sethforprivacy/simple-monero-wallet-rpc-docker. It works great.

xmrsale commented 2 years ago

Great idea, will make the docker smoother after this next release.