179 lines
3.7 KiB
Markdown
179 lines
3.7 KiB
Markdown
# Admin Panel Deployment Guide
|
|
|
|
## 🚀 Quick Start
|
|
|
|
### 1. Clone Repository
|
|
```bash
|
|
cd /opt
|
|
git clone https://gitea.argeict.net/argeict/admin-panel.git
|
|
cd admin-panel
|
|
```
|
|
|
|
### 2. Configure Environment
|
|
```bash
|
|
cp .env.example .env
|
|
nano .env
|
|
```
|
|
|
|
Update the following:
|
|
- `SECRET_KEY` - Random secret key
|
|
- `JWT_SECRET_KEY` - Random JWT secret
|
|
- `CUSTOMER_API_URL` - Customer platform API URL
|
|
- `CUSTOMER_API_INTERNAL_KEY` - Internal API key
|
|
- `CORS_ORIGINS` - Allowed origins
|
|
|
|
### 3. Build and Run
|
|
```bash
|
|
docker-compose up -d --build
|
|
```
|
|
|
|
### 4. Initialize Database
|
|
```bash
|
|
docker exec -it admin-panel-backend python -c "
|
|
from app.main import app, db
|
|
from app.models import AdminUser
|
|
with app.app_context():
|
|
db.create_all()
|
|
# Create default admin
|
|
admin = AdminUser(
|
|
username='admin',
|
|
email='admin@argeict.net',
|
|
full_name='System Admin'
|
|
)
|
|
admin.set_password('admin123')
|
|
db.session.add(admin)
|
|
db.session.commit()
|
|
print('Database initialized!')
|
|
"
|
|
```
|
|
|
|
## 🌐 Nginx Configuration
|
|
|
|
### Backend API (admin-api.argeict.net)
|
|
```nginx
|
|
server {
|
|
listen 80;
|
|
server_name admin-api.argeict.net;
|
|
|
|
location / {
|
|
proxy_pass http://localhost:5001;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
}
|
|
```
|
|
|
|
### Frontend (admin.argeict.net)
|
|
```nginx
|
|
server {
|
|
listen 80;
|
|
server_name admin.argeict.net;
|
|
|
|
location / {
|
|
proxy_pass http://localhost:5173;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
}
|
|
```
|
|
|
|
### Enable SSL with Certbot
|
|
```bash
|
|
certbot --nginx -d admin.argeict.net -d admin-api.argeict.net
|
|
```
|
|
|
|
## 📊 Default Credentials
|
|
|
|
**Username:** admin
|
|
**Password:** admin123
|
|
|
|
⚠️ **IMPORTANT:** Change the default password immediately after first login!
|
|
|
|
## 🔧 Maintenance
|
|
|
|
### View Logs
|
|
```bash
|
|
docker-compose logs -f backend
|
|
docker-compose logs -f frontend
|
|
```
|
|
|
|
### Restart Services
|
|
```bash
|
|
docker-compose restart
|
|
```
|
|
|
|
### Update Application
|
|
```bash
|
|
git pull
|
|
docker-compose up -d --build
|
|
```
|
|
|
|
### Backup Database
|
|
```bash
|
|
docker cp admin-panel-backend:/app/data/admin_panel.db ./backup-$(date +%Y%m%d).db
|
|
```
|
|
|
|
## 🔐 Security Checklist
|
|
|
|
- [ ] Change default admin password
|
|
- [ ] Update SECRET_KEY and JWT_SECRET_KEY
|
|
- [ ] Configure CORS_ORIGINS properly
|
|
- [ ] Enable SSL/HTTPS
|
|
- [ ] Set up firewall rules
|
|
- [ ] Regular database backups
|
|
- [ ] Monitor audit logs
|
|
|
|
## 📝 API Endpoints
|
|
|
|
### Authentication
|
|
- `POST /api/auth/login` - Admin login
|
|
- `GET /api/auth/me` - Get current admin
|
|
- `POST /api/auth/logout` - Logout
|
|
|
|
### Plans
|
|
- `GET /api/plans` - List all plans
|
|
- `POST /api/plans` - Create plan
|
|
- `PUT /api/plans/:id` - Update plan
|
|
- `DELETE /api/plans/:id` - Delete plan
|
|
|
|
### CF Accounts
|
|
- `GET /api/cf-accounts` - List CF accounts
|
|
- `POST /api/cf-accounts` - Create CF account
|
|
- `PUT /api/cf-accounts/:id` - Update CF account
|
|
- `DELETE /api/cf-accounts/:id` - Delete CF account
|
|
|
|
### Customers
|
|
- `GET /api/customers` - List customers
|
|
- `GET /api/customers/:id` - Get customer details
|
|
- `PUT /api/customers/:id/plan` - Update customer plan
|
|
|
|
## 🐛 Troubleshooting
|
|
|
|
### Backend not starting
|
|
```bash
|
|
docker logs admin-panel-backend
|
|
```
|
|
|
|
### Frontend not building
|
|
```bash
|
|
docker logs admin-panel-frontend
|
|
```
|
|
|
|
### Database issues
|
|
```bash
|
|
docker exec -it admin-panel-backend python -c "
|
|
from app.main import app, db
|
|
with app.app_context():
|
|
db.create_all()
|
|
"
|
|
```
|
|
|
|
## 📞 Support
|
|
|
|
For issues, check the logs or contact the development team.
|
|
|