Production & Development Setup: - Multi-stage Dockerfile with optimized build (node:20-alpine) - docker-compose.yml for production with PostgreSQL - docker-compose.dev.yml for development with hot reload - Dockerfile.dev for development environment - .dockerignore to reduce build context Features: - Health checks for both app and database - Non-root user security (nextjs:nodejs) - Resource limits (CPU/memory) - Volume persistence for logs and database - PostgreSQL 16 with automatic initialization - Network isolation with custom bridge network Helper Scripts: - docker-build.sh - Build production image - docker-start.sh - Start all services - docker-stop.sh - Stop containers safely - docker-logs.sh - View real-time logs Documentation: - DOCKER.md - Complete deployment guide with: * Quick start commands * Production deployment steps * Development hot reload setup * Configuration examples * Docker commands reference * Troubleshooting guide * Best practices for security & performance Configuration: - Environment-based configuration via .env - Safe defaults for testing ($50 positions) - Separate dev/prod compose files - Debug mode with Node.js inspector (port 9229) - Log rotation and resource monitoring Ready for deployment with: cd v4 && ./docker-start.sh
37 lines
820 B
Bash
Executable File
37 lines
820 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Trading Bot v4 - Docker Build Script
|
|
# Builds production-ready Docker image
|
|
|
|
set -e
|
|
|
|
echo "🐳 Building Trading Bot v4 Docker Image..."
|
|
echo ""
|
|
|
|
# Navigate to v4 directory
|
|
cd "$(dirname "$0")"
|
|
|
|
# Check if .env exists
|
|
if [ ! -f ".env" ]; then
|
|
echo "⚠️ Warning: .env file not found!"
|
|
echo " Creating from .env.example..."
|
|
cp .env.example .env
|
|
echo " ✅ .env created. Please edit it with your credentials."
|
|
echo ""
|
|
fi
|
|
|
|
# Build with BuildKit for better performance
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
echo "📦 Building image with BuildKit..."
|
|
docker-compose build --progress=plain
|
|
|
|
echo ""
|
|
echo "✅ Build complete!"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Edit .env file with your credentials"
|
|
echo " 2. Run: docker-compose up -d"
|
|
echo " 3. Check logs: docker-compose logs -f"
|
|
echo ""
|