Add Docker deployment files and deployment guide
This commit is contained in:
parent
736a1487ab
commit
9a2745cd92
|
|
@ -0,0 +1,20 @@
|
|||
# Admin Panel Environment Variables
|
||||
|
||||
# Flask
|
||||
SECRET_KEY=your-secret-key-here
|
||||
DEBUG=False
|
||||
|
||||
# Database (SQLite for dev, PostgreSQL for production)
|
||||
DATABASE_URL=sqlite:///data/admin_panel.db
|
||||
# DATABASE_URL=postgresql://admin_user:admin_pass@localhost/admin_hosting_db
|
||||
|
||||
# JWT
|
||||
JWT_SECRET_KEY=your-jwt-secret-here
|
||||
|
||||
# Customer API
|
||||
CUSTOMER_API_URL=http://customer-backend:5000
|
||||
CUSTOMER_API_INTERNAL_KEY=your-internal-api-key-here
|
||||
|
||||
# CORS
|
||||
CORS_ORIGINS=https://admin.argeict.net,http://localhost:5173
|
||||
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
# 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.
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application
|
||||
COPY . .
|
||||
|
||||
# Create data directory for SQLite
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# Expose port
|
||||
EXPOSE 5001
|
||||
|
||||
# Run application
|
||||
CMD ["python", "-m", "app.main"]
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
# Backend API
|
||||
backend:
|
||||
build: ./backend
|
||||
container_name: admin-panel-backend
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5001:5001"
|
||||
environment:
|
||||
- SECRET_KEY=${SECRET_KEY}
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- JWT_SECRET_KEY=${JWT_SECRET_KEY}
|
||||
- CUSTOMER_API_URL=${CUSTOMER_API_URL}
|
||||
- CUSTOMER_API_INTERNAL_KEY=${CUSTOMER_API_INTERNAL_KEY}
|
||||
- CORS_ORIGINS=${CORS_ORIGINS}
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
- admin-db-data:/app/data
|
||||
networks:
|
||||
- admin-network
|
||||
|
||||
# Frontend
|
||||
frontend:
|
||||
build: ./frontend
|
||||
container_name: admin-panel-frontend
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5173:80"
|
||||
environment:
|
||||
- VITE_API_URL=https://admin-api.argeict.net
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
- admin-network
|
||||
|
||||
volumes:
|
||||
admin-db-data:
|
||||
|
||||
networks:
|
||||
admin-network:
|
||||
driver: bridge
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
FROM node:18-alpine as build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY package.json .
|
||||
RUN npm install
|
||||
|
||||
# Copy source
|
||||
COPY . .
|
||||
|
||||
# Build
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copy built files
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
# Copy nginx config
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Gzip compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;
|
||||
|
||||
# SPA routing
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue