Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions Dockerfile.miner
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ FROM python:3.11-slim

LABEL maintainer="RustChain Community"
LABEL description="RustChain Proof-of-Antiquity Miner"
LABEL version="1.0.0"
LABEL version="1.1.0"

# Build argument for miner type
ARG MINER_TYPE=linux
ARG MINER_ARCH=x86_64

# Environment variables
# ENV WALLET_NAME and NODE_URL are read at runtime by docker-miner-entrypoint.sh
ENV PYTHONUNBUFFERED=1 \
WALLET_NAME="" \
NODE_URL="https://rustchain.org" \
Expand All @@ -39,22 +38,19 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY miners/ ./miners/
COPY wallet/ ./wallet/

# Copy color logs helper
COPY miners/color_logs.py ./
# Copy entrypoint script (must happen before USER switch)
COPY docker-miner-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Create a non-root user (security best practice)
RUN useradd -m -u 1000 rustchain && \
chown -R rustchain:rustchain /app

USER rustchain

# Health check
# Health check - verify the node is reachable
HEALTHCHECK --interval=5m --timeout=30s --start-period=1m --retries=3 \
CMD curl -f ${NODE_URL}/health || exit 1

# Entry point script
COPY docker-miner-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD curl -fsk ${NODE_URL}/health || exit 1

ENTRYPOINT ["/entrypoint.sh"]

Expand Down
40 changes: 16 additions & 24 deletions docker-compose.miner.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
rustchain-miner:
build:
Expand All @@ -10,21 +8,20 @@ services:
- MINER_ARCH=x86_64
container_name: rustchain-miner
restart: unless-stopped

# Environment variables (configure these via .env.miner)
env_file:
- .env.miner

# Environment variables
# Set WALLET_NAME via shell env or .env file in the same directory
environment:
- WALLET_NAME=${WALLET_NAME}
- WALLET_NAME=${WALLET_NAME:?Set WALLET_NAME to your RTC wallet address}
- NODE_URL=${NODE_URL:-https://rustchain.org}
- BLOCK_TIME=${BLOCK_TIME:-600}
- PYTHONUNBUFFERED=1

# Volume for persistent data
volumes:
- miner-data:/app/data
# Resource limits (optional)

# Resource limits
deploy:
resources:
limits:
Expand All @@ -33,35 +30,30 @@ services:
reservations:
cpus: '0.5'
memory: 128M

# Logging configuration
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"

# Network mode
network_mode: "bridge"

volumes:
miner-data:
driver: local

# Usage:
# 1. Set your wallet name:
# export WALLET_NAME=RTC27a4b8256b4d3c63737b27e96b181223cc8774ae
# 1. Set your wallet name:
# export WALLET_NAME=RTC27a4b8256b4d3c63737b27e96b181223cc8774ae
#
# 2. Run the miner:
# docker-compose up -d
# 2. Run the miner:
# docker compose -f docker-compose.miner.yml up -d
#
# 3. View logs:
# docker-compose logs -f rustchain-miner
# 3. View logs:
# docker compose -f docker-compose.miner.yml logs -f
#
# 4. Stop the miner:
# docker-compose down
# 4. Stop the miner:
# docker compose -f docker-compose.miner.yml down
#
# Note: Docker miners receive reduced rewards due to anti-VM detection.
# For maximum rewards, run the miner directly on physical hardware.
# 0. Create .env.miner (from template) and set WALLET_NAME
# cp .env.miner.example .env.miner
4 changes: 3 additions & 1 deletion docker-miner-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ echo ""
echo "[START] Launching miner: $MINER_SCRIPT"
echo ""

exec python3 -u "$MINER_SCRIPT" --wallet "$WALLET_NAME" --node "$NODE_URL"
# NODE_URL is already exported as an environment variable for the miner.
# The miner CLI accepts --wallet but reads NODE_URL from the environment.
exec python3 -u "$MINER_SCRIPT" --wallet "$WALLET_NAME"
Loading