diff --git a/rin/miner/.devcontainer/devcontainer.json b/rin/miner/.devcontainer/devcontainer.json new file mode 100644 index 0000000..25b4f8c --- /dev/null +++ b/rin/miner/.devcontainer/devcontainer.json @@ -0,0 +1,27 @@ +{ + "name": "RinHash Build Environment", + "dockerFile": "../Dockerfile.windows-build", + "context": "..", + "remoteUser": "root", + "mounts": [ + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" + ], + "extensions": [ + "ms-vscode.vscode-docker", + "ms-vscode-remote.remote-ssh", + "ms-vscode-remote.remote-containers", + "ms-vscode.cmake-tools", + "ms-vscode.cpptools" + ], + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "docker.host": "unix:///var/run/docker.sock", + "C_Cpp.default.compilerPath": "/usr/bin/gcc", + "C_Cpp.default.cStandard": "c11", + "C_Cpp.default.cppStandard": "c++11", + "cmake.configureOnOpen": false + }, + "postCreateCommand": "apt-get update && apt-get install -y docker.io git", + "forwardPorts": [], + "shutdownAction": "stopContainer" +} diff --git a/rin/miner/.vscode/settings.json b/rin/miner/.vscode/settings.json index 65f20cc..9b29c69 100644 --- a/rin/miner/.vscode/settings.json +++ b/rin/miner/.vscode/settings.json @@ -23,13 +23,31 @@ "C_Cpp.default.defines": [ "HAVE_CONFIG_H" ], + "docker.host": "tcp://localhost:2375", + "docker.certificates": [], + "docker.tlsVerify": false, + "docker.machineName": "", + "docker.context": "default", + "docker.showExplorer": true, + "docker.containers.groupBy": "Image", + "docker.containers.showRunningOnly": false, + "docker.images.groupBy": "Repository", + "docker.images.showDanglingImages": false, + "docker.volumes.groupBy": "none", + "docker.networks.groupBy": "none", + "docker.contexts.groupBy": "none", + "docker.commands.build": "docker build --pull --rm -f \"${file}\" -t ${tag} \"${context}\"", + "docker.commands.run": "docker run --rm -d ${exposedPorts} ${tag}", + "docker.commands.runInteractive": "docker run --rm -it ${exposedPorts} ${tag}", "search.exclude": { "**/build/**": true, "**/complete-build-output/**": true, "**/hip-output/**": true, "**/rocm-direct-output/**": true, "**/*.o": true, - "**/*.exe": true + "**/*.exe": true, + "**/node_modules/**": true, + "**/.git/**": true }, "files.exclude": { "**/build/**": false, @@ -39,5 +57,8 @@ }, "task.quickOpen.detail": true, "task.quickOpen.showAll": true, - "task.saveBeforeRun": "prompt" + "task.saveBeforeRun": "prompt", + "remote.SSH.configFile": "~/.ssh/config", + "remote.SSH.showLoginTerminal": true, + "remote.SSH.useLocalServer": true } diff --git a/rin/miner/BUILD_GUIDE.md b/rin/miner/BUILD_GUIDE.md index d3e0e6a..af1a7ed 100644 --- a/rin/miner/BUILD_GUIDE.md +++ b/rin/miner/BUILD_GUIDE.md @@ -36,6 +36,196 @@ If you're using VS Code, the project now includes pre-configured tasks for easy - โœ… Integrated terminal output in VS Code - โœ… One-click building from the IDE +## ๐Ÿณ Remote Docker Access Options + +You don't need to SSH as root every time! Here are several ways to use Docker remotely from another machine: + +### Option 1: VS Code Docker Extension (Easiest - Recommended) +```bash +# On the build machine (where Docker is running) - Quick setup: +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +./setup-remote-docker.sh + +# Or manually: +sudo systemctl enable docker +sudo systemctl start docker +sudo usermod -aG docker $USER # Add user to docker group +``` + +**In VS Code on your local machine:** +1. Install "Docker" extension by Microsoft +2. Install "Remote-SSH" extension for SSH tunneling +3. Connect to build machine: `Ctrl+Shift+P` โ†’ "Remote-SSH: Connect to Host" +4. Use VS Code Docker extension to manage containers remotely + +### Option 2: Docker Remote API (Advanced) +```bash +# On the build machine - enable Docker API over TCP: +sudo mkdir -p /etc/systemd/system/docker.service.d +sudo tee /etc/systemd/system/docker.service.d/override.conf > /dev/null <nul 2>&1 +if %errorlevel% neq 0 ( + echo โŒ Error: Docker Desktop is not installed or not in PATH + echo. + echo Please install Docker Desktop for Windows: + echo 1. Download from: https://www.docker.com/products/docker-desktop + echo 2. Enable WSL 2 integration during installation + echo 3. Restart this script after installation + echo. + pause + exit /b 1 +) + +echo โœ… Docker Desktop found: +docker --version +echo. + +REM Check if SSH is available +ssh -V >nul 2>&1 +if %errorlevel% neq 0 ( + echo โŒ Error: OpenSSH Client is not available + echo. + echo Please enable OpenSSH Client: + echo Settings โ†’ Apps โ†’ Optional features โ†’ Add "OpenSSH Client" + echo. + pause + exit /b 1 +) + +echo โœ… OpenSSH Client available +echo. + +echo ๐Ÿ“‹ Next Steps: +echo. +echo 1. On your Linux build machine, run: +echo cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +echo ./setup-remote-docker.sh +echo. +echo 2. Get your Linux machine IP address +echo. +echo 3. Set up SSH port forwarding (replace LINUX_IP with actual IP): +echo ssh -L localhost:2375:/var/run/docker.sock user@LINUX_IP +echo. +echo 4. In a NEW PowerShell/Command Prompt window, set environment: +echo PowerShell: $env:DOCKER_HOST = "tcp://localhost:2375" +echo CMD: set DOCKER_HOST=tcp://localhost:2375" +echo. +echo 5. Test remote connection: +echo docker run --rm cpuminer-windows-builder echo "Remote Docker working!" +echo. +echo 6. Build the miner: +echo docker run --rm -v "%CD%:/work" -v "%CD%/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows-smart.sh" +echo. + +REM Create a PowerShell setup script +echo Creating setup script... +( +echo # PowerShell Remote Docker Setup Helper +echo # Run this after setting up SSH port forwarding +echo. +echo # Set Docker to use remote host +echo $env:DOCKER_HOST = "tcp://localhost:2375" +echo. +echo # Test connection +echo Write-Host "Testing remote Docker connection..." -ForegroundColor Green +echo docker ps +echo. +echo # Test RinHash build container +echo Write-Host "Testing RinHash build container..." -ForegroundColor Green +echo docker run --rm cpuminer-windows-builder echo "Build container ready!" +echo. +echo # Build commands +echo Write-Host "Build Commands:" -ForegroundColor Yellow +echo "# Smart build (recommended)" +echo docker run --rm -v "`${PWD}:/work" -v "`${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows-smart.sh" +echo. +echo "# Manual build" +echo docker run --rm -v "`${PWD}:/work" -v "`${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows.sh" +echo. +echo "# Clean build" +echo docker run --rm -v "`${PWD}:/work" -v "`${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && make clean" +) > setup-remote-docker-windows.ps1 + +echo โœ… Created setup helper: setup-remote-docker-windows.ps1 +echo. +echo ๐Ÿ“– For detailed instructions, see: +echo REMOTE_DOCKER_README.md +echo BUILD_GUIDE.md +echo. +echo ๐ŸŽ‰ Happy remote building from Windows 11! ๐Ÿš€ +echo. +pause diff --git a/rin/miner/setup-remote-docker-windows.ps1 b/rin/miner/setup-remote-docker-windows.ps1 new file mode 100644 index 0000000..ee9a22a --- /dev/null +++ b/rin/miner/setup-remote-docker-windows.ps1 @@ -0,0 +1,125 @@ +# PowerShell Remote Docker Setup for RinHash Miner +# Windows 11 helper script for setting up remote Docker access + +Write-Host "" +Write-Host "๐Ÿณ Windows 11 Remote Docker Setup" -ForegroundColor Cyan +Write-Host "==================================" -ForegroundColor Cyan +Write-Host "" + +# Check Docker Desktop +try { + $dockerVersion = docker --version 2>$null + Write-Host "โœ… Docker Desktop found: $dockerVersion" -ForegroundColor Green +} catch { + Write-Host "โŒ Error: Docker Desktop is not installed or not in PATH" -ForegroundColor Red + Write-Host "" + Write-Host "Please install Docker Desktop for Windows:" -ForegroundColor Yellow + Write-Host "1. Download from: https://www.docker.com/products/docker-desktop" -ForegroundColor White + Write-Host "2. Enable WSL 2 integration during installation" -ForegroundColor White + Write-Host "3. Restart PowerShell and run this script again" -ForegroundColor White + Read-Host "Press Enter to exit" + exit 1 +} + +# Check SSH +try { + $sshVersion = ssh -V 2>$null + Write-Host "โœ… OpenSSH Client available" -ForegroundColor Green +} catch { + Write-Host "โŒ Error: OpenSSH Client is not available" -ForegroundColor Red + Write-Host "" + Write-Host "Please enable OpenSSH Client:" -ForegroundColor Yellow + Write-Host "Settings โ†’ Apps โ†’ Optional features โ†’ Add 'OpenSSH Client'" -ForegroundColor White + Read-Host "Press Enter to exit" + exit 1 +} + +Write-Host "" +Write-Host "๐Ÿ“‹ Setup Instructions:" -ForegroundColor Magenta +Write-Host "" + +Write-Host "1. On your Linux build machine, run:" -ForegroundColor Yellow +Write-Host " cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner" -ForegroundColor White +Write-Host " ./setup-remote-docker.sh" -ForegroundColor White +Write-Host "" + +$linuxIP = Read-Host "2. Enter your Linux build machine IP address" +$userName = Read-Host "3. Enter your Linux username" + +Write-Host "" +Write-Host "4. Set up SSH port forwarding:" -ForegroundColor Yellow +Write-Host " In a NEW PowerShell window, run:" -ForegroundColor White +Write-Host " ssh -L localhost:2375:/var/run/docker.sock ${userName}@${linuxIP}" -ForegroundColor Cyan +Write-Host "" + +Write-Host "5. In ANOTHER PowerShell window, run these commands:" -ForegroundColor Yellow +Write-Host " # Set Docker to use remote host" -ForegroundColor Gray +Write-Host " `$env:DOCKER_HOST = 'tcp://localhost:2375'" -ForegroundColor Cyan +Write-Host "" +Write-Host " # Test connection" -ForegroundColor Gray +Write-Host " docker ps" -ForegroundColor Cyan +Write-Host "" +Write-Host " # Test RinHash build container" -ForegroundColor Gray +Write-Host " docker run --rm cpuminer-windows-builder echo 'Build container ready!'" -ForegroundColor Cyan +Write-Host "" + +Write-Host "6. Build the RinHash miner:" -ForegroundColor Yellow +Write-Host " # Smart build (recommended)" -ForegroundColor Gray +Write-Host " docker run --rm -v `"`${PWD}:/work`" -v `"`${PWD}/build/win:/output`" cpuminer-windows-builder bash -c `"cd /work && ./build-windows-smart.sh`"" -ForegroundColor Cyan +Write-Host "" + +Write-Host "๐Ÿ“– For detailed instructions, see:" -ForegroundColor Magenta +Write-Host " REMOTE_DOCKER_README.md" -ForegroundColor White +Write-Host " BUILD_GUIDE.md" -ForegroundColor White +Write-Host "" + +Write-Host "๐ŸŽ‰ Ready for remote building from Windows 11!" -ForegroundColor Green +Write-Host "" + +# Create a helper script for easy connection +$helperScript = @" +# RinHash Remote Docker Helper +# Run this in PowerShell after setting up SSH port forwarding + +# Set environment +`$env:DOCKER_HOST = "tcp://localhost:2375" + +Write-Host "๐Ÿ”— Connected to remote Docker daemon" -ForegroundColor Green +Write-Host "" + +# Function to build RinHash +function Build-RinHash { + param([string]`$buildType = "smart") + + switch (`$buildType) { + "smart" { + docker run --rm -v "`${PWD}:/work" -v "`${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows-smart.sh" + } + "manual" { + docker run --rm -v "`${PWD}:/work" -v "`${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows.sh" + } + "clean" { + docker run --rm -v "`${PWD}:/work" -v "`${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && make clean" + } + } +} + +# Export functions +Export-ModuleMember -Function Build-RinHash + +Write-Host "Available commands:" -ForegroundColor Yellow +Write-Host " Build-RinHash smart # Smart build (recommended)" -ForegroundColor White +Write-Host " Build-RinHash manual # Manual build" -ForegroundColor White +Write-Host " Build-RinHash clean # Clean build" -ForegroundColor White +"@ + +$helperScript | Out-File -FilePath "rinhash-remote-helper.ps1" -Encoding UTF8 + +Write-Host "โœ… Created helper script: rinhash-remote-helper.ps1" -ForegroundColor Green +Write-Host "" +Write-Host "To use the helper script:" -ForegroundColor Yellow +Write-Host " . .\rinhash-remote-helper.ps1" -ForegroundColor White +Write-Host " Build-RinHash smart" -ForegroundColor White +Write-Host "" + +Read-Host "Press Enter to continue" diff --git a/rin/miner/setup-remote-docker.sh b/rin/miner/setup-remote-docker.sh new file mode 100644 index 0000000..e5d1f78 --- /dev/null +++ b/rin/miner/setup-remote-docker.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# +# RinHash Miner - Remote Docker Setup Script +# This script helps set up remote Docker access for building from another machine +# + +set -e + +echo "๐Ÿณ RinHash Miner - Remote Docker Setup" +echo "=====================================" +echo "" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Check if running as root +if [[ $EUID -eq 0 ]]; then + echo -e "${RED}โŒ Please do not run this script as root!${NC}" + echo "Run as a regular user with sudo access." + exit 1 +fi + +# Check if Docker is installed +if ! command -v docker &> /dev/null; then + echo -e "${RED}โŒ Docker is not installed!${NC}" + echo "Please install Docker first:" + echo " sudo apt update && sudo apt install -y docker.io" + exit 1 +fi + +echo -e "${BLUE}๐Ÿ“‹ Checking current Docker status...${NC}" +sudo systemctl status docker --no-pager -l || true + +echo "" +echo -e "${BLUE}๐Ÿ”ง Setting up Docker access...${NC}" + +# Add user to docker group +echo "Adding user to docker group..." +sudo usermod -aG docker $USER + +# Enable and start Docker service +echo "Enabling and starting Docker service..." +sudo systemctl enable docker +sudo systemctl start docker + +# Test Docker access +echo "" +echo -e "${BLUE}๐Ÿงช Testing Docker access...${NC}" +if docker ps &> /dev/null; then + echo -e "${GREEN}โœ… Docker access working!${NC}" +else + echo -e "${YELLOW}โš ๏ธ Docker access may require logout/login or 'newgrp docker'${NC}" +fi + +# Show Docker version and info +echo "" +echo -e "${BLUE}๐Ÿ“Š Docker Information:${NC}" +docker --version +docker system info --format "Server Version: {{.ServerVersion}}\nOperating System: {{.OperatingSystem}}\nArchitecture: {{.Architecture}}" + +# Test the build container +echo "" +echo -e "${BLUE}๐Ÿš€ Testing RinHash build container...${NC}" +if docker run --rm cpuminer-windows-builder echo "RinHash build environment ready!" 2>/dev/null; then + echo -e "${GREEN}โœ… Build container working!${NC}" +else + echo -e "${YELLOW}โš ๏ธ Build container not found. You may need to pull it:${NC}" + echo " docker pull cpuminer-windows-builder" +fi + +echo "" +echo -e "${GREEN}๐ŸŽ‰ Setup Complete!${NC}" +echo "" +echo -e "${BLUE}๐Ÿ“– Next Steps:${NC}" +echo "" +echo "1. ${YELLOW}For SSH tunneling (Recommended - Most Secure):${NC}" +echo " From your local machine:" +echo " ssh -L localhost:2375:/var/run/docker.sock $USER@$(hostname -I | awk '{print $1}')" +echo " export DOCKER_HOST=tcp://localhost:2375" +echo "" +echo "2. ${YELLOW}For Docker contexts:${NC}" +echo " docker context create remote-build --docker \"host=ssh://$USER@$(hostname -I | awk '{print $1}')\"" +echo " docker context use remote-build" +echo "" +echo "3. ${YELLOW}For VS Code Remote Development:${NC}" +echo " - Install VS Code extensions: Docker, Remote-SSH" +echo " - Use Command Palette: Remote-SSH: Connect to Host" +echo " - Run build tasks from VS Code" +echo "" +echo "4. ${YELLOW}Test remote access:${NC}" +echo " docker run --rm cpuminer-windows-builder echo 'Remote Docker working!'" +echo "" +echo -e "${BLUE}๐Ÿ“ Build Commands:${NC}" +echo " ./build-windows-smart.sh # Smart build with curl detection" +echo " ./build-windows.sh # Manual build" +echo "" +echo -e "${GREEN}Happy building! ๐Ÿš€${NC}"