Skip to content

Instantly share code, notes, and snippets.

@tarfeef101
Last active March 16, 2022 09:23
Show Gist options
  • Save tarfeef101/4b6c3a3bbc4e017b5225b39bbb912e41 to your computer and use it in GitHub Desktop.
Save tarfeef101/4b6c3a3bbc4e017b5225b39bbb912e41 to your computer and use it in GitHub Desktop.
Dockerized Raptoreum/Ghostrider Miner
This file exists because of how naming gists works in GitHub. This system needs to be improved, a lot.
tune_config
docker-compose.yaml
Dockerfile
README.md
'!dockerized_raptoreum_ghostrider_miner'

NOTE: This is deprecated, and is maintained in a "real" repo at https://github.com/tarfeef101/raptoreum_miner_docker

Purpose

I set up this simple Docker setup to mine Raptoreum because I was cold and needed a bit more heat, and this seemed to be popular. I also hate using things that aren't in containers, so now we have this :D There is a Dockerfile in the repo for the provider of the miner, but that's to build, which is more bloated than I need. Also, if you use this without reading/configuring, you're gonna mine for me, so while that's awesome and I appreciate it, you probably don't want to do that, and should read on. When you configure this as instructed, I will get nothing, the only "losses" you'll have are the dev fee for the mining client, which I have nothing to do with. I set those as low as possible, but that's all I can do.

Usage

  • Set the following environment variables, as desired
    • URL (str) for the URL to mine to (default value is to zergpool). I do recommend something other than the default flockpool to encourage decentralization
    • URL_BACKUP (str) for the backup URL should the former be unresponsive (default is the NA endpoint for zergpool)
    • USERNAME (str) to set your stratum username
    • PASSWORD (str) to set your stratum password
    • ALGO (str) to change the algorithm (default is gr/ghostminer)
    • THREADS (int) to set the amount of threads (not cores) to use, default is unlimited
    • DONATION (float) to set the donation amount in percent, default is 0 (will set the minimum, currently 1.75% for gr only)
    • TUNE_FULL (boolean, json style) set to true to do an "in-depth" tune, default is false
  • Uncomment the volumes section to mount in a tune_config file if you have one generated. Otherwise, the entrypoint script will generate one on startup, which takes a couple hours, then start mining after that. Highly recommend you uncomment this to persist the config file. You may choose to find one online for your CPU, do this at your own discretion.
  • Run the service with docker-compose up -d, it should pull the latest from Docker Hub. If you want to ensure the build is the latest, run docker-compose up --build -d to build locally.
#!/bin/sh
tag=$(curl -fsSL https://api.github.com/repos/WyvernTKC/cpuminer-gr-avx2/releases/latest | jq -r '.tag_name')
curl -fsSL https://github.com/WyvernTKC/cpuminer-gr-avx2/releases/download/"$tag"/cpuminer-gr-"$tag"-x86_64_linux.tar.gz -o cpuminer-gr-"$tag"-x86_64_linux.tar.gz
tar -xzf cpuminer-gr-"$tag"-x86_64_linux.tar.gz
rm cpuminer-gr-"$tag"-x86_64_linux.tar.gz
mv cpuminer-gr-"$tag"-x86_64_linux/* .
rm -rf cpuminer-gr-"$tag"-x86_64_linux/
version: "3"
services:
mining:
image: tarfeef101/raptorminer
build: .
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "1"
#environment:
#- THREADS=16
#volumes:
#- "./tune_config:/opt/tune_config"
FROM alpine:latest AS builder
WORKDIR /opt
COPY build.sh /opt
RUN apk add curl jq && \
/opt/build.sh
FROM debian:11-slim
RUN apt update && \
apt install -y libcurl4
COPY --from=builder /opt /opt/
COPY entrypoint.sh /opt/entrypoint.sh
WORKDIR /opt
CMD ./entrypoint.sh
#!/bin/bash
# handle params
if [ -z "$URL" ]; then
URL="stratum+tcp://ghostrider.mine.zergpool.com:5354"
fi
if [ -z "$URL_BACKUP" ]; then
URL_BACKUP="stratum+tcp://ghostrider.na.mine.zergpool.com:5354"
fi
if [ -z "$USERNAME" ]; then
USERNAME="0xD392FB8868131B04Aff7055A643fF58aF23aE001"
fi
if [ -z "$PASSWORD" ]; then
PASSWORD="c=ETH,ID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
fi
if [ -z "$ALGO" ]; then
ALGO="gr"
fi
if [ -z "$THREADS" ]; then
THREADS=0
fi
if [ -z "$DONATION" ]; then
DONATION="0"
fi
if [ -z "$TUNE_FULL" ]; then
TUNE_FULL=false
fi
# create json settings since we can't use flags :(
fmt_str='{
"url": "%s",
"url-backup": "%s",
"user": "%s",
"pass": "%s",
"algo": "%s",
"threads": %s,
"donation": %s,
"tune-full": %s,
"tune-config": "tune_config",
'
# if we have to tune, set those opts
if [ ! -f /opt/tune_config ]; then
fmt_str+='"no-tune": false,
"force-tune": true,
"benchmark": true,
"stress-test": false,
"quiet": false
}
'
# else set these opts
else
fmt_str+='"no-tune": true,
"force-tune": false,
"benchmark": false,
"stress-test": false,
"quiet": false
}
'
fi
# dump to file
printf "$fmt_str" "$URL" "$URL_BACKUP" "$USERNAME" "$PASSWORD" "$ALGO" "$THREADS" "$DONATION" "$TUNE_FULL" > config.json
# tune if no config
# benchmark is suboptimal, but will still exit after tuning and benching for like 20 min
if [ ! -f /opt/tune_config ]; then
./cpuminer.sh
sed -i 's/"benchmark": true/"benchmark": false/g' config.json
fi
# run the miner
./cpuminer.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment