Merge pull request #71 from bladedoyle/docker-compose

docker-compose project for Monero P2Pool and all requirements
This commit is contained in:
SChernykh 2021-11-11 22:00:29 +01:00 committed by GitHub
commit 2d559ca764
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 326 additions and 0 deletions

50
Dockerfile Normal file
View file

@ -0,0 +1,50 @@
FROM ubuntu:latest
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
git \
build-essential \
ca-certificates \
cmake \
libuv1-dev \
libzmq3-dev \
libsodium-dev \
libpgm-dev \
libnorm-dev \
libgss-dev
ADD . /usr/src/p2pool
WORKDIR /usr/src/p2pool
RUN git submodule update --init --recursive && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc)
# ---
FROM ubuntu:latest
COPY --from=0 /usr/src/p2pool/build/p2pool /
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
libzmq5 \
libuv1 \
&& \
apt-get clean
RUN groupadd -r p2pool -g 1000 && \
useradd -u 1000 -r -g p2pool -s /sbin/nologin -c "p2pool user" p2pool
RUN mkdir -p /home/p2pool/.p2pool && \
chown p2pool.p2pool /home/p2pool /home/p2pool/.p2pool
USER p2pool
EXPOSE 3333
EXPOSE 37889
VOLUME /home/p2pool/.p2pool
WORKDIR /home/p2pool/.p2pool
ENTRYPOINT ["/p2pool"]

38
docker-compose/.env Normal file
View file

@ -0,0 +1,38 @@
##
# Monero Wallet Address for mining rewards (replace this with your own address)
WALLET_ADDRESS="44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg"
##
# p2pool settings
#
# Which port to listen for miner connections
P2POOL_STRATUM_PORT=3333
#
# How much logging - (Less) 0 - 6 (More)
P2POOL_LOGLEVEL=2
#
# The name of docker volume to hold p2pool data (created automatically if it doesnt exist)
P2POOL_VOLUME=p2pool
##
# Monero Node Settings
#
# Version of Monero to build
MONERO_GIT_TAG=release-v0.17
#
# Limit the size of the blockchain on disk (comment to disable)
PRUNE_NODE="--prune-blockchain"
#
# The name of docker volume to hold p2pool data (created automatically if it doesnt exist)
MONERO_VOLUME=monero
##
# Xmrig Miner Settings
#
# Submit shares at a lower fixed difficulty to show mining progress (comment to disable, edit to customize)
FIXED_MINING_DIFFICULTY="-u x+500000"
#
# Limit the number of CPU cores to use for mining (uncomment to enable, edit to customize)
#NUM_MINING_CPU="-t 4"

38
docker-compose/README.md Normal file
View file

@ -0,0 +1,38 @@
# Monero P2Pool Docker Compose
Run your own <b>Monero Node + P2Pool + XMRig</b> in Docker
## Instructions
#### Install docker and docker-compose
[Install Docker](https://docs.docker.com/engine/install/)
[Install Docker Compose](https://docs.docker.com/compose/install/)
#### Clone the P2Pool project
```
git clone --recursive https://github.com/SChernykh/p2pool
```
#### Configure your Monero address for mining rewards
```
cd p2pool/docker-compose
vi .env
```
<b>WALLET_ADDRESS</b> is the only setting that needs to be updated in that file
#### Build the docker containers
```
docker-compose build
```
#### Run the node, pool, and CPU miner
```
docker-compose up
```
#### Optional
* You can run everythng in the background by adding the "-d" argument to the "docker-compose up" command: ```docker-compose up -d```
* You can see logs when running in the background for with the "docker logs" command: ```docker logs -f p2pool-xmrig``` or ```docker logs -f p2pool-p2pool``` or ```docker logs -f p2pool-monero```
* Open ports 18080 (Monero p2p port) and 37889 (P2Pool p2p port) in your firewall to ensure better connectivity. If you're mining from a computer behind NAT (like a router) you could consider forwarding the ports to your local machine
* An XMRig CPU miner is included by default, but you can connect additional miners to this same p2pool node using port 3333
* Configure your kernel for maximum mining performance: [XMRig RandomX Optimization Guide](https://xmrig.com/docs/miner/randomx-optimization-guide)

View file

@ -0,0 +1,84 @@
version: '3.4'
networks:
p2pool:
driver: bridge
volumes:
p2pool:
name: ${P2POOL_VOLUME}
monero:
name: ${MONERO_VOLUME}
services:
monero:
image: monero:latest
build:
context: monero
args:
- MONERO_GIT_TAG=$MONERO_GIT_TAG
container_name: p2pool-monero
networks:
- p2pool
ports:
- 18080:18080/tcp
volumes:
- monero:/home/monero/.bitmonero:rw
- /dev/null:/home/monero/.bitmonero/bitmonero.log:rw
- /dev/hugepages:/dev/hugepages:rw
restart: unless-stopped
command: >-
--zmq-pub tcp://0.0.0.0:18083
--disable-dns-checkpoints
--enable-dns-blocklist
--non-interactive
--p2p-bind-ip=0.0.0.0
--p2p-bind-port=18080
--rpc-bind-ip=0.0.0.0
--rpc-bind-port=18081
--confirm-external-bind
${PRUNE_NODE}
p2pool:
image: p2pool:latest
build: ../
container_name: p2pool-p2pool
networks:
- p2pool
ports:
- ${P2POOL_STRATUM_PORT}:3333/tcp
- 37889:37889/tcp
volumes:
- p2pool:/home/p2pool/.p2pool:rw
- /dev/null:/home/p2pool/.p2pool/p2pool.log:rw
- /dev/hugepages:/dev/hugepages:rw
depends_on:
- monero
restart: unless-stopped
command: >-
--host monero
--wallet ${WALLET_ADDRESS}
--loglevel ${P2POOL_LOGLEVEL}
xmrig:
image: xmrig:latest
build: xmrig
container_name: p2pool-xmrig
networks:
- p2pool
privileged: true
cap_add:
- ALL
volumes:
- /dev:/dev:ro
- /lib/modules:/lib/modules:ro
- /dev/hugepages:/dev/hugepages:rw
depends_on:
- p2pool
restart: unless-stopped
command: >-
${FIXED_MINING_DIFFICULTY}
${NUM_MINING_CPU}
--randomx-1gb-pages
-o p2pool:3333

View file

@ -0,0 +1,79 @@
FROM ubuntu:latest
ARG MONERO_GIT_TAG="master"
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
git \
ca-certificates \
build-essential \
pkg-config \
cmake \
libuv1-dev \
libzmq3-dev \
libsodium-dev \
libpgm-dev \
libnorm-dev \
libgss-dev \
libssl-dev \
libzmq3-dev \
libunbound-dev \
libsodium-dev \
libunwind8-dev \
liblzma-dev \
libreadline6-dev \
libldns-dev \
libexpat1-dev \
libpgm-dev \
qttools5-dev-tools \
libhidapi-dev \
libusb-1.0-0-dev \
libprotobuf-dev \
protobuf-compiler \
libudev-dev \
libboost-chrono-dev \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-locale-dev \
libboost-program-options-dev \
libboost-regex-dev \
libboost-serialization-dev \
libboost-system-dev \
libboost-thread-dev \
ccache \
doxygen \
graphviz
WORKDIR /usr/src
RUN git clone --recursive https://github.com/monero-project/monero && \
cd monero && \
git checkout $MONERO_GIT_TAG && \
git submodule sync && git submodule update --init --force --recursive && \
make release-static -j$(nproc)
# ---
FROM ubuntu:latest
ARG MONERO_GIT_TAG="master"
COPY --from=0 /usr/src/monero/build/Linux/$MONERO_GIT_TAG/release/bin/* /
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
libgssapi-krb5-2 \
&& \
apt-get clean
RUN groupadd -r monero -g 1000 && \
useradd -u 1000 -r -g monero -s /sbin/nologin -c "monero node user" monero
RUN mkdir -p /home/monero/.bitmonero && \
chown monero.monero /home/monero /home/monero/.bitmonero
USER monero
EXPOSE 18080 18081 18083
VOLUME /home/monero/.bitmonero
WORKDIR /home/monero
ENTRYPOINT ["/monerod"]

View file

@ -0,0 +1,37 @@
FROM ubuntu:latest
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
git \
build-essential \
ca-certificates \
cmake \
libuv1-dev \
libssl-dev \
libhwloc-dev
WORKDIR /usr/src
RUN git clone https://github.com/xmrig/xmrig.git && \
mkdir xmrig/build && \
cd xmrig/build && \
cmake .. && \
make -j$(nproc)
# ---
FROM ubuntu:latest
COPY --from=0 /usr/src/xmrig/build/xmrig /
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
libssl1.1 \
libcrypto++6 \
libhwloc15 \
&& \
apt-get clean
WORKDIR /
ENTRYPOINT ["/xmrig"]