# Blockscout Next Steps - After Database Verification

## ✅ Database Status: VERIFIED

Your Blockscout database is properly initialized:
- ✅ Database connection working
- ✅ All critical tables exist (`blocks`, `transactions`, `migrations_status`)
- ✅ Migrations completed successfully

## Remaining Issues to Check

Based on the original problem summary, there are two remaining potential issues:

### 1. Static Assets (cache_manifest.json)

**Check if assets are built:**
```bash
# From VMID 5000
BLOCKSCOUT_CONTAINER=$(docker ps -a | grep blockscout | grep -v postgres | awk '{print $1}' | head -1)
docker exec -it $BLOCKSCOUT_CONTAINER test -f priv/static/cache_manifest.json && \
  echo "✅ Assets built" || echo "❌ Assets missing"
```

**If missing, build assets:**
```bash
docker exec -it $BLOCKSCOUT_CONTAINER mix phx.digest
```

### 2. Startup Command in Docker Compose

**Check docker-compose.yml:**
```bash
# From VMID 5000
grep -A 5 "blockscout:" /opt/blockscout/docker-compose.yml | grep "command:"
```

**If missing, add startup command:**
```bash
cd /opt/blockscout
sed -i '/blockscout:/a\    command: bin/blockscout start' docker-compose.yml
```

### 3. Container Status

**Check if Blockscout is running:**
```bash
# From VMID 5000
docker ps | grep blockscout
docker logs blockscout 2>&1 | tail -30
```

**If container is crashing, check logs for errors:**
```bash
docker logs blockscout 2>&1 | grep -i error | tail -20
```

## Complete Status Check

Run the automated status check script:

```bash
# From Proxmox host
cd /home/intlc/projects/proxmox/explorer-monorepo
./scripts/check-blockscout-status.sh
```

Or manually from VMID 5000:

```bash
# 1. Check container status
docker ps -a | grep blockscout

# 2. Check static assets
BLOCKSCOUT_CONTAINER=$(docker ps -a | grep blockscout | grep -v postgres | awk '{print $1}' | head -1)
docker exec -it $BLOCKSCOUT_CONTAINER ls -la priv/static/cache_manifest.json 2>/dev/null || echo "Assets missing"

# 3. Check docker-compose config
grep "command:" /opt/blockscout/docker-compose.yml

# 4. Check logs
docker logs blockscout 2>&1 | tail -30
```

## Quick Fix Commands

If issues are found, run these fixes:

```bash
# From VMID 5000

# 1. Build assets (if missing)
BLOCKSCOUT_CONTAINER=$(docker ps -a | grep blockscout | grep -v postgres | awk '{print $1}' | head -1)
docker exec -it $BLOCKSCOUT_CONTAINER mix phx.digest

# 2. Fix docker-compose startup command
cd /opt/blockscout
if ! grep -q "command:.*blockscout start" docker-compose.yml; then
    sed -i '/blockscout:/a\    command: bin/blockscout start' docker-compose.yml
fi

# 3. Restart Blockscout
docker compose restart blockscout
# Or if using docker directly:
docker restart blockscout

# 4. Verify it's running
sleep 10
docker ps | grep blockscout
docker logs blockscout 2>&1 | tail -20
```

## Expected Final Status

After all fixes, you should see:

1. ✅ **Database**: All tables exist (already verified)
2. ✅ **Static Assets**: `cache_manifest.json` exists
3. ✅ **Docker Compose**: Has `command: bin/blockscout start`
4. ✅ **Container**: Running and healthy
5. ✅ **API**: Responding at `http://localhost:4000/api/v2/stats`

## Verification

Test Blockscout is fully working:

```bash
# From VMID 5000 or host
curl -s http://localhost:4000/api/v2/stats | jq . || curl -s http://localhost:4000/api/v2/stats

# Should return JSON with stats
```

## Summary

- ✅ **Database**: Fully initialized and working
- ⚠️ **Assets**: Need to verify if built
- ⚠️ **Startup Command**: Need to verify docker-compose config
- ⚠️ **Container**: Need to verify it's running properly

Run the status check script to see what still needs to be fixed!

