|
| 1 | +# LesMee Development Environment |
| 2 | + |
| 3 | +This guide covers how to set up and use the LesMee development environment using Docker Compose. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | +- Docker Desktop installed and running |
| 9 | +- Git |
| 10 | + |
| 11 | +### Setup |
| 12 | +```bash |
| 13 | +# Clone the repository (if not already done) |
| 14 | +git clone <repository-url> |
| 15 | +cd lesmee-full |
| 16 | + |
| 17 | +# Start the development environment |
| 18 | +docker-compose -f docker-compose.dev.yml --env-file .env.dev up --build -d |
| 19 | +``` |
| 20 | + |
| 21 | +### Access Services |
| 22 | +Once started, you can access: |
| 23 | +- **Frontend**: http://localhost:5173 (React/Vite with hot reload) |
| 24 | +- **Backend API**: http://localhost:8000 (FastAPI with auto-reload) |
| 25 | +- **API Documentation**: http://localhost:8000/docs (Swagger UI) |
| 26 | +- **Health Check**: http://localhost:8000/api/v1/utils/health-check/ (Database + Redis status) |
| 27 | + |
| 28 | +## Services Overview |
| 29 | + |
| 30 | +### Database (PostgreSQL) |
| 31 | +- **Port**: 5432 |
| 32 | +- **Host**: localhost |
| 33 | +- **Database**: lesmee_dev |
| 34 | +- **Username**: postgres |
| 35 | +- **Password**: postgres123 |
| 36 | + |
| 37 | +Connect with your favorite PostgreSQL client (DBeaver, pgAdmin, TablePlus, etc.) |
| 38 | + |
| 39 | +### Redis |
| 40 | +- **Port**: 6379 |
| 41 | +- **Host**: localhost |
| 42 | +- **Password**: redis123 |
| 43 | + |
| 44 | +Use Redis CLI or Redis GUI tools like RedisInsight. |
| 45 | + |
| 46 | +### Backend (FastAPI) |
| 47 | +- **Port**: 8000 |
| 48 | +- **Auto-reload**: Enabled |
| 49 | +- **API Docs**: http://localhost:8000/docs |
| 50 | +- **Health Check**: http://localhost:8000/api/v1/utils/health-check/ |
| 51 | + |
| 52 | +### Frontend (React/Vite) |
| 53 | +- **Port**: 5173 |
| 54 | +- **Hot Reload**: Enabled |
| 55 | +- **Dev Server**: Vite development server |
| 56 | + |
| 57 | +## Development Workflow |
| 58 | + |
| 59 | +### Making Changes |
| 60 | +1. **Backend**: Edit files in `./backend/` - changes trigger automatic reload |
| 61 | +2. **Frontend**: Edit files in `./frontend/` - changes trigger hot reload via Vite |
| 62 | + |
| 63 | +### Environment Variables |
| 64 | +Edit `.env.dev` to customize development settings: |
| 65 | +- Database credentials |
| 66 | +- Redis configuration |
| 67 | +- Admin user credentials |
| 68 | +- CORS origins |
| 69 | + |
| 70 | +### Database Management |
| 71 | +```bash |
| 72 | +# Access database container |
| 73 | +docker-compose -f docker-compose.dev.yml exec db psql -U postgres -d lesmee_dev |
| 74 | + |
| 75 | +# Run migrations manually |
| 76 | +docker-compose -f docker-compose.dev.yml exec backend alembic upgrade head |
| 77 | + |
| 78 | +# Create new migration |
| 79 | +docker-compose -f docker-compose.dev.yml exec backend alembic revision --autogenerate -m "description" |
| 80 | +``` |
| 81 | + |
| 82 | +### Redis Management |
| 83 | +```bash |
| 84 | +# Access Redis CLI |
| 85 | +docker-compose -f docker-compose.dev.yml exec redis redis-cli |
| 86 | + |
| 87 | +# Authenticate with password |
| 88 | +AUTH redis123 |
| 89 | +``` |
| 90 | + |
| 91 | +## Useful Commands |
| 92 | + |
| 93 | +### Environment Management |
| 94 | +```bash |
| 95 | +# Start development environment |
| 96 | +./scripts/dev-start.sh |
| 97 | + |
| 98 | +# Stop development environment |
| 99 | +./scripts/dev-stop.sh |
| 100 | + |
| 101 | +# View logs for all services |
| 102 | +docker-compose -f docker-compose.dev.yml logs -f |
| 103 | + |
| 104 | +# View logs for specific service |
| 105 | +docker-compose -f docker-compose.dev.yml logs -f backend |
| 106 | +docker-compose -f docker-compose.dev.yml logs -f frontend |
| 107 | +docker-compose -f docker-compose.dev.yml logs -f db |
| 108 | +docker-compose -f docker-compose.dev.yml logs -f redis |
| 109 | +``` |
| 110 | + |
| 111 | +### Container Management |
| 112 | +```bash |
| 113 | +# Rebuild specific service |
| 114 | +docker-compose -f docker-compose.dev.yml up --build -d backend |
| 115 | + |
| 116 | +# Restart specific service |
| 117 | +docker-compose -f docker-compose.dev.yml restart backend |
| 118 | + |
| 119 | +# Execute commands in containers |
| 120 | +docker-compose -f docker-compose.dev.yml exec backend bash |
| 121 | +docker-compose -f docker-compose.dev.yml exec frontend sh |
| 122 | +``` |
| 123 | + |
| 124 | +### Cleaning Up |
| 125 | +```bash |
| 126 | +# Stop and remove containers, networks, volumes |
| 127 | +docker-compose -f docker-compose.dev.yml down -v |
| 128 | + |
| 129 | +# Remove all unused Docker resources |
| 130 | +docker system prune -a --volumes |
| 131 | +``` |
| 132 | + |
| 133 | +## Default Credentials |
| 134 | + |
| 135 | +### Admin User |
| 136 | + |
| 137 | +- **Password**: admin123 |
| 138 | + |
| 139 | +### Database |
| 140 | +- **Host**: localhost |
| 141 | +- **Port**: 5432 |
| 142 | +- **Database**: lesmee_dev |
| 143 | +- **Username**: postgres |
| 144 | +- **Password**: postgres123 |
| 145 | + |
| 146 | +### Redis |
| 147 | +- **Host**: localhost |
| 148 | +- **Port**: 6379 |
| 149 | +- **Password**: redis123 |
| 150 | + |
| 151 | +## Troubleshooting |
| 152 | + |
| 153 | +### Port Conflicts |
| 154 | +If ports are already in use, modify them in `docker-compose.dev.yml`: |
| 155 | +```yaml |
| 156 | +ports: |
| 157 | + - "5433:5432" # PostgreSQL on 5433 |
| 158 | + - "6380:6379" # Redis on 6380 |
| 159 | +``` |
| 160 | +
|
| 161 | +### Permission Issues |
| 162 | +If you encounter permission errors, ensure Docker has proper permissions and consider: |
| 163 | +```bash |
| 164 | +# Fix Docker permissions on Linux/Mac |
| 165 | +sudo chown -R $USER:$USER ./ |
| 166 | +``` |
| 167 | + |
| 168 | +### Backend Build Issues |
| 169 | +If backend fails to start: |
| 170 | +1. Check logs: `docker-compose -f docker-compose.dev.yml logs backend` |
| 171 | +2. Ensure `.env.dev` exists and is correctly configured |
| 172 | +3. Try rebuilding: `docker-compose -f docker-compose.dev.yml up --build -d backend` |
| 173 | + |
| 174 | +### Frontend Build Issues |
| 175 | +If frontend fails to start: |
| 176 | +1. Check logs: `docker-compose -f docker-compose.dev.yml logs frontend` |
| 177 | +2. Ensure node_modules volume is properly mounted |
| 178 | +3. Try rebuilding: `docker-compose -f docker-compose.dev.yml up --build -d frontend` |
| 179 | + |
| 180 | +## Development Best Practices |
| 181 | + |
| 182 | +1. **Use Version Control**: Commit changes frequently with descriptive messages |
| 183 | +2. **Environment Variables**: Keep sensitive data in `.env.dev`, don't commit it |
| 184 | +3. **Database Migrations**: Always create migrations for schema changes |
| 185 | +4. **Code Quality**: Use linters and formatters configured in the project |
| 186 | +5. **Testing**: Run tests before committing changes |
| 187 | +6. **Documentation**: Update this file when making architectural changes |
| 188 | + |
| 189 | +## Production Deployment |
| 190 | + |
| 191 | +For production deployment, use the main `docker-compose.yml` file with Traefik reverse proxy, not this development setup. |
| 192 | + |
| 193 | +## Need Help? |
| 194 | + |
| 195 | +- Check the logs for detailed error messages |
| 196 | +- Refer to the main project documentation |
| 197 | +- Open an issue in the project repository |
0 commit comments