GitHub Actions CI/CD Pipeline (.github/workflows/ci.yml): - Automated testing for backend, frontend, and smart contracts - Security scanning with Trivy - Docker image building on main branch - Deployment validation checks - Multi-job workflow with dependency management Docker Infrastructure: - Production-optimized Dockerfile with multi-stage build - Base image: oven/bun:1 for fast runtime - Non-root user for security (botuser) - Health check integration - Optimized layer caching - docker-compose.yml for easy deployment - Single-command deployment - Volume management for logs and data - Network isolation - Health checks and restart policies - Ready for PostgreSQL and Redis integration - .dockerignore for optimized builds - Excludes node_modules, tests, docs - Reduces image size significantly DevOps Scripts: - scripts/healthcheck.ts - Container health verification - HTTP health endpoint check - Exit codes for Docker health status - Used by Docker HEALTHCHECK directive - scripts/monitor.ts - Bot monitoring and statistics - Real-time bot status display - Trading performance metrics (win rate, P/L) - System information - Watch mode for continuous monitoring - Performance indicators and alerts - scripts/backup.sh - Automated backup system - Backs up logs, data, configs - Excludes secrets for security - Compression and retention (keeps last 7) - Backup metadata and restore instructions - scripts/setup.sh - Developer onboarding - Interactive setup wizard - Dependency installation (Bun, Node.js) - Environment file creation - Directory structure setup - Optional Hardhat installation - Next steps guidance Environment Templates: - .env.development - Safe defaults for local dev - Testnet configuration - Conservative trading limits - Debug logging enabled - .env.production (template only, not committed) - Mainnet configuration - Production security settings - Monitoring integrations - Strong API key requirements Package.json Scripts: - monitor: Check bot status and performance - monitor⌚ Continuous monitoring - backup: Create system backups - setup: Run setup wizard - docker:build: Build Docker image - docker:run: Start with Docker Compose - docker:stop: Stop containers - docker:logs: View container logs - validate: Pre-deployment validation Documentation: - DOCKER.md - Complete Docker deployment guide - Quick start instructions - Configuration management - Multi-architecture builds - Docker Compose usage - Monitoring and logging - Backup and restore procedures - Production best practices - Troubleshooting guide - CI/CD integration examples This infrastructure enables: ✅ One-command deployment (docker-compose up) ✅ Automated testing and security scanning ✅ Production-grade monitoring and health checks ✅ Easy developer onboarding (setup.sh) ✅ Comprehensive backup and disaster recovery ✅ CI/CD pipeline for automated deployments ✅ Multi-environment support (dev/prod)
53 lines
1.4 KiB
Bash
Executable File
53 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Setup script for smart contract development and deployment
|
|
|
|
echo "🔧 Setting up smart contract environment..."
|
|
echo ""
|
|
|
|
# Check if Node.js is installed
|
|
if ! command -v node &> /dev/null; then
|
|
echo "❌ Node.js not found. Please install Node.js 18+ first."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Node version: $(node --version)"
|
|
echo "NPM version: $(npm --version)"
|
|
echo ""
|
|
|
|
# Install Hardhat and dependencies
|
|
echo "📦 Installing Hardhat and dependencies..."
|
|
npm install --save-dev \
|
|
hardhat \
|
|
@nomicfoundation/hardhat-toolbox \
|
|
@nomicfoundation/hardhat-verify \
|
|
@openzeppelin/contracts \
|
|
@typechain/ethers-v6 \
|
|
@typechain/hardhat \
|
|
typechain \
|
|
@types/node
|
|
|
|
echo ""
|
|
echo "✅ Hardhat setup complete!"
|
|
echo ""
|
|
|
|
# Display next steps
|
|
echo "📝 Next Steps:"
|
|
echo ""
|
|
echo "1. Ensure .env file has required variables:"
|
|
echo " - WALLET_PRIVATE_KEY (your deployer wallet private key)"
|
|
echo " - BSC_TESTNET_RPC (optional, defaults to public RPC)"
|
|
echo " - BSCSCAN_API_KEY (for contract verification)"
|
|
echo ""
|
|
echo "2. Compile contracts:"
|
|
echo " npx hardhat compile"
|
|
echo ""
|
|
echo "3. Deploy token to testnet:"
|
|
echo " npx hardhat run scripts/deploy-token.ts --network bscTestnet"
|
|
echo ""
|
|
echo "4. Deploy staking contract:"
|
|
echo " npx hardhat run scripts/deploy-staking.ts --network bscTestnet"
|
|
echo ""
|
|
echo "5. Verify contracts on BscScan:"
|
|
echo " npx hardhat verify --network bscTestnet <CONTRACT_ADDRESS> <CONSTRUCTOR_ARGS>"
|
|
echo ""
|