Skip to content

Instantly share code, notes, and snippets.

@kdmukai
Last active June 20, 2024 12:35
Show Gist options
  • Save kdmukai/123d21d73475d96aa36d2e64bf30169d to your computer and use it in GitHub Desktop.
Save kdmukai/123d21d73475d96aa36d2e64bf30169d to your computer and use it in GitHub Desktop.
Create a mempool.space instance in Proxmox

Create a mempool.space instance in Proxmox

Assumes you've already set up a bitcoind and Fulcrum instance.

Create the CT

  • Debian 12 image
  • 4 CPU cores
  • 8GB disk in local-lvm
  • 4096 MB RAM, 0 MB swap

Add a /data volume

Only ~1GB for logs and config

Enable ssh

nano /etc/ssh/sshd_config

# In sshd_config:
PermitRootLogin yes

Exit and save changes, restart ssh

/etc/init.d/ssh restart

Install docker

Modified from the steps here: https://docs.docker.com/engine/install/debian/

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg; done
# Add Docker's official GPG key:
apt update && apt upgrade -y
apt install ca-certificates curl gnupg -y
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
   tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
docker run hello-world

Clone the mempool.space project

apt install git -y
git clone https://github.com/mempool/mempool.git

Set permissions on dirs needed by the container

cd ~/mempool/docker
chown -R 1000:1000 mysql

Configure to connect to Fulcrum

Edit the docker-compose.yml:

nano docker-compose.yml

# In the text editor, update the "api" section:
# Update the MEMPOOL_BACKEND and add the ELECTRUM_* params
# Update the CORE_RPC_* params for the Bitcoin Core instance
  api:
    environment:
      MEMPOOL_BACKEND: "electrum"
      ELECTRUM_HOST: "192.168.1.203"  # customize for your Fulcrum CT
      ELECTRUM_PORT: "50001"
      ELECTRUM_TLS_ENABLED: "false"
      CORE_RPC_HOST: "192.168.1.201"  # customize for your bitcoind CT
      CORE_RPC_PORT: "8332"
      CORE_RPC_USERNAME: "mempool_user"
      CORE_RPC_PASSWORD: "<rpc user's password>"
      CORE_RPC_TIMEOUT: "60000"

note: If connecting to Fulcrum via TLS, set ELECTRUM_PORT to 50002 and ELECTRUM_TLS_ENABLED to "true"

Start the mempool.space container

# from inside /root/mempool/docker
docker compose up

If successful, the webserver will be running port 80

Shut down the container

# CTRL-C or:
docker compose down

Set up as a service to run automatically

nano /etc/systemd/system/mempool.service

# In the text editor:
[Unit]
Description=mempool
After=network.target

[Service]
WorkingDirectory=/root/mempool/docker
ExecStart=/usr/bin/docker compose up
TimeoutStopSec=30min
Restart=always
StandardOutput=append:/data/stdout.log
StandardError=append:/data/stdout.log

[Install]
WantedBy=multi-user.target

Load the new service and run:

systemctl enable mempool
systemctl start mempool

If you make further service config changes, load your new changes with:

systemctl daemon-reload

Set up logrotate

nano /etc/logrotate.d/mempool.conf

# config details
/data/*.log {
    minage 2
    rotate 6
    size 10M
    compress
    delaycompress
    endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment