add docker for server demo

This commit is contained in:
arifal
2025-06-26 18:28:26 +07:00
parent c33193d5f0
commit a7f578ca3d
23 changed files with 2420 additions and 431 deletions

191
README.md
View File

@@ -1,112 +1,167 @@
# Usage icon
# Sibedas PBG Web
search or pick icon in <a href="https://icon-sets.iconify.design/mingcute/?keyword=mingcute">here</a>
Aplikasi web untuk manajemen data PBG (Pendidikan Berkelanjutan Guru) dengan fitur integrasi Google Sheets.
# Set up queue for running automatically
## 🚀 Quick Start
- Install Supervisor
### Prerequisites
```
sudo apt update && sudo apt install supervisor -y
- Docker & Docker Compose
- Domain name (untuk production)
### Local Development
```bash
git clone <repository-url>
cd sibedas-pbg-web
./scripts/setup-local.sh
# Access: http://localhost:8000
```
- Create Supervisor Config
### Production Deployment
```
sudo nano /etc/supervisor/conf.d/laravel-worker.conf
```bash
# 1. Setup environment
cp env.production.example .env
nano .env
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/arifal/development/sibedas-pbg-web/artisan queue:work --queue=default --timeout=82800 --tries=1
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true
stdout_logfile=/home/arifal/development/sibedas-pbg-web/storage/logs/worker.log
stopasgroup=true
killasgroup=true
# 2. Deploy with SSL (Recommended)
./scripts/setup-reverse-proxy.sh setup
# 3. Check status
./scripts/setup-reverse-proxy.sh status
# Access: https://yourdomain.com
```
- Reload Supervisor
## 🏗️ Architecture
### Local Development
```
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker
sudo supervisorctl restart laravel-worker
sudo supervisorctl status
Browser → Port 8000 → Nginx → PHP-FPM → MariaDB
```
# How to running
- Install composer package
### Production dengan Reverse Proxy
```
composer install
Internet → Reverse Proxy (80/443) → Internal Nginx → PHP-FPM → MariaDB
```
- Install npm package
## 🔧 Configuration
```
npm install && npm run build
### Environment Variables
```bash
# Domain & SSL
DOMAIN=sibedas.yourdomain.com
EMAIL=admin@yourdomain.com
SSL_TYPE=self-signed # atau letsencrypt
# Database
DB_PASSWORD=your_secure_password
MYSQL_ROOT_PASSWORD=your_root_password
# Laravel
APP_KEY=base64:your_app_key_here
APP_URL=https://sibedas.yourdomain.com
```
- Create symlinks storage
## 🚀 Production Deployment Steps
```
php artisan storage:link
### 1. Server Preparation
```bash
# Install Docker & Docker Compose
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
```
- Running migration
### 2. Clone & Setup
```
php artisan migrate
```bash
git clone <repository-url>
cd sibedas-pbg-web
chmod +x scripts/*.sh
cp env.production.example .env
nano .env
```
- Running seeder
### 3. Deploy
```
php artisan db:seed
```bash
# Full deployment with SSL
./scripts/setup-reverse-proxy.sh setup
# Or step by step
./scripts/deploy-production.sh deploy
./scripts/setup-ssl.sh letsencrypt
```
- Create view table
- excute all sql queries on folder database/view_query
### 4. Verify
# Add ENV variable
- API_KEY_GOOGLE
```
Get api key from google developer console for and turn on spreadsheet api or feaature for google sheet
```bash
docker-compose ps
./scripts/setup-reverse-proxy.sh status
curl -f http://localhost/health-check
```
- SPREAD_SHEET_ID
## 📊 Monitoring
```
Get spreadsheet id from google sheet link
```bash
# Check status
./scripts/setup-reverse-proxy.sh status
# View logs
docker-compose logs [service]
# Check SSL certificate
./scripts/setup-ssl.sh check
```
- OPENAI_API_KEY
## 🛠️ Common Commands
```
Get OpenAI API key from chatgpt subscription
```bash
# Start services
docker-compose up -d
# Stop services
docker-compose down
# Restart services
docker-compose restart
# Execute Laravel commands
docker-compose exec app php artisan [command]
# Backup database
docker exec sibedas_db mysqldump -u root -p sibedas > backup.sql
```
- ENV
## 📁 Scripts
```
### Essential Scripts
API_KEY_GOOGLE="xxxxx"
SPREAD_SHEET_ID="xxxxx"
OPENAI_API_KEY="xxxxx"
- `scripts/setup-reverse-proxy.sh` - Setup lengkap reverse proxy dan SSL
- `scripts/deploy-production.sh` - Deployment production
- `scripts/setup-ssl.sh` - Setup SSL certificates
```
### Optional Scripts
# Technology version
- `scripts/setup-local.sh` - Setup local development
- `scripts/import-sibedas-database.sh` - Manual database import
- php 8.3
- Laravel 11
- node v22.13.0
- npm 10.9.2
- mariadb Ver 15.1 Distrib 10.6.18-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
- Ubuntu 24.04
## 📚 Documentation
Untuk dokumentasi lengkap, lihat [docs/README.md](docs/README.md)
## 🆘 Support
1. Check logs: `docker-compose logs [service]`
2. Check status: `./scripts/setup-reverse-proxy.sh status`
3. Restart services: `docker-compose restart`
4. Review documentation di folder `docs/`