bug fixes
Some checks failed
Publish Alpha Package to npm / publish (push) Has been cancelled

This commit is contained in:
anonpenguin 2025-04-09 01:42:07 +03:00
parent 8e32807361
commit f936c5bcde
7 changed files with 123 additions and 3 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ radata/
dist/ dist/
blockstore/ blockstore/
orbitdb/ orbitdb/
keys/
swarm.key swarm.key
.DS_Store .DS_Store
bin/ bin/

View File

@ -1,13 +1,35 @@
# Installation # Installation
## Run this script: ## Production Installation
Run this script for production deployment:
```bash ```bash
sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/DeBrosOfficial/node/refs/heads/main/scripts/install.sh)" sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/DeBrosOfficial/node/refs/heads/main/scripts/install.sh)"
``` ```
## Local Development
For local development, we have a streamlined workflow:
```bash
# Clone the repository
git clone https://github.com/DeBrosOfficial/node.git
cd node
# Start the development environment
./scripts/start-dev.sh
```
This will:
1. Automatically generate a `.env` file if it doesn't exist
2. Create development keys in the `keys/` directory
3. Start the Docker Compose development environment
## Stop and Clean (optional for debugging) ## Stop and Clean (optional for debugging)
### Production
```bash ```bash
#!/bin/bash #!/bin/bash
@ -15,3 +37,13 @@ sudo systemctl stop debros-node
sudo rm -rf /opt/debros-node sudo rm -rf /opt/debros-node
docker system prune -a docker system prune -a
``` ```
### Development
```bash
# Stop containers
docker-compose -f docker-compose.dev.yml down
# Clean environment (optional)
rm -rf ./keys ./.env ./orbitdb ./blockstore ./logs
```

View File

@ -10,11 +10,13 @@ services:
volumes: volumes:
- ./orbitdb:/app/orbitdb - ./orbitdb:/app/orbitdb
- ./blockstore:/app/blockstore - ./blockstore:/app/blockstore
- ./keys:/app/keys
- ./.env:/app/.env - ./.env:/app/.env
- ./terms-agreement:/app/terms-agreement - ./terms-agreement:/app/terms-agreement
- ./logs:/app/logs - ./logs:/app/logs
environment: environment:
- PORT=7777 - PORT=7777
- NODE_ENV=development
# Add other environment variables if needed # Add other environment variables if needed
networks: networks:
- debros-network - debros-network

View File

@ -17,7 +17,7 @@
] ]
}, },
"scripts": { "scripts": {
"dev": "npx tsx ./src/server.ts", "dev": "./scripts/start-dev.sh",
"dev:with-anyone": "npx tsx ./src/server.ts", "dev:with-anyone": "npx tsx ./src/server.ts",
"start": "NODE_ENV=production node dist/server.js", "start": "NODE_ENV=production node dist/server.js",
"lint": "npx eslint src", "lint": "npx eslint src",

View File

@ -1,2 +1,3 @@
packages: packages:
- 'packages/**' # - 'packages/**'
- '../network'

74
scripts/generate-dev-env.sh Executable file
View File

@ -0,0 +1,74 @@
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NOCOLOR='\033[0m'
log() {
echo -e "${CYAN}[DEV SETUP]${NOCOLOR} $1"
}
# Base directory - the project root
BASE_DIR=$(dirname "$(dirname "$(readlink -f "$0")")")
KEY_DIR="$BASE_DIR/keys"
KEY_NAME="debros_key"
# Create .env file if it doesn't exist
if [ ! -f "$BASE_DIR/.env" ]; then
log "Generating .env file for development..."
# Create keys directory
mkdir -p "$KEY_DIR"
chmod 700 "$KEY_DIR"
# Generate keypair if it doesn't exist
if [ ! -f "$KEY_DIR/$KEY_NAME" ]; then
log "Creating new key pair..."
ssh-keygen -t ed25519 -f "$KEY_DIR/$KEY_NAME" -N "" -q
log "${GREEN}Keys created in $KEY_DIR${NOCOLOR}"
fi
# Calculate fingerprint
FINGERPRINT=$(ssh-keygen -l -f "$KEY_DIR/$KEY_NAME.pub" 2>/dev/null | awk '{print $2}' | sed 's/SHA256://' | base64 -d 2>/dev/null | xxd -p -u | tr -d '\n' | head -c 40)
# Default dev values
NICKNAME="dev_node"
ADMIN_WALLET="devWallet123456789"
# Create the .env file with development settings
cat > "$BASE_DIR/.env" << EOF
NICKNAME=$NICKNAME
FINGERPRINT=$FINGERPRINT
NODE_ENV=development
PORT=7777
ENABLE_ANYONE=true
HOSTNAME=localhost
ADMIN_WALLET=$ADMIN_WALLET
ENABLE_LOAD_BALANCING=true
SERVICE_DISCOVERY_TOPIC=debros-service-discovery
HEARTBEAT_INTERVAL=5000
STALE_PEER_TIMEOUT=30000
PEER_LOG_INTERVAL=60000
NODE_PUBLIC_ADDRESS=localhost
BOOTSTRAP_NODES=/ip4/188.166.113.190/tcp/7778/p2p/12D3KooWNWgs4WAUmE4CsxrL6uuyv1yuTzcRReMe5r7Psemsg2Z9,/ip4/82.208.21.140/tcp/7778/p2p/12D3KooWPUdpNX5N6dsuFAvgwfBMXUoFK2QS5sh8NpjxbfGpkSCi
MAX_CONNECTIONS=1000
LOAD_BALANCING_STRATEGY=least-loaded
ACCEPT_TERMS=true
KEY_PATH=./keys
LIBP2P_DEBUG=true
IPFS_DEBUG=true
LOG_LEVEL=debug
DEBUG=libp2p:*
EOF
log "${GREEN}Development .env file created successfully${NOCOLOR}"
log "Keys location: $KEY_DIR"
else
log "${GREEN}Development .env file already exists${NOCOLOR}"
fi
# Make the script executable
chmod +x "$0"
log "${GREEN}Development environment setup complete${NOCOLOR}"

10
scripts/start-dev.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# Navigate to project root
cd "$(dirname "$(dirname "$(readlink -f "$0")")")"
# Generate development environment if needed
./scripts/generate-dev-env.sh
# Start the development container
docker-compose -f docker-compose.dev.yml up --build