Deployment
Halaman ini menjelaskan langkah-langkah dan pertimbangan untuk men-deploy ILDIS ke lingkungan production. Jika Anda baru menginstal ILDIS, lihat halaman Instalasi terlebih dahulu.
Struktur Direktori Instalasi
Section titled “Struktur Direktori Instalasi”Setelah instalasi dengan metode Pasang Cepat, berikut adalah struktur direktori yang dibuat di folder instalasi (default: /opt/ildis):
| File/Direktori | Keterangan |
|---|---|
.env | Konfigurasi environment — database, port, domain, SSL, reCAPTCHA, cookie key |
docker-compose.yml | Konfigurasi Docker Compose — mendefinisikan container app, database (db), cron, dan Traefik |
nginx/default.conf | Konfigurasi Nginx dalam container — routing frontend dan backend |
traefik/traefik.yml | Konfigurasi utama Traefik — entrypoints, log level, certificates resolver |
traefik/config.yml | Konfigurasi dinamis Traefik — routing rules dan redirect HTTP→HTTPS |
ssl/ | Direktori untuk sertifikat SSL manual |
logs/nginx/ | Log Nginx — akses dan error log |
logs/traefik/ | Log Traefik — akses dan error log |
VERSION | File versi ILDIS — digunakan oleh script update |
backups/ | Direktori backup — dibuat saat menjalankan ./install.sh --update |
File .env
Section titled “File .env”File .env adalah konfigurasi utama yang mengatur seluruh aspek ILDIS. Berikut adalah variabel penting yang dapat Anda ubah:
| Variabel | Keterangan | Default |
|---|---|---|
YII_ENV | Lingkungan aplikasi (dev, prod) | prod |
YII_DEBUG | Mode debug (true/false) | false |
PORT | Port aplikasi | 8080 |
PUBLIC_DOMAIN | URL publik aplikasi | http://localhost:8080 |
DB_TYPE | Tipe database (mariadb, mysql, external) | mariadb |
DB_HOST | Host database | db (nama container) |
DB_USER | Pengguna database | ildis |
DB_PASSWORD | Kata sandi database | (dibuat otomatis) |
DB_DATABASE | Nama database | ildis_v4 |
COOKIE_VALIDATION_KEY_BE | Kunci validasi cookie backend | (dibuat otomatis) |
COOKIE_VALIDATION_KEY_FE | Kunci validasi cookie frontend | (dibuat otomatis) |
RECAPTCHA_ENABLED | Aktifkan reCAPTCHA | false |
RECAPTCHA_SITE_KEY | Kunci publik reCAPTCHA | kosong |
RECAPTCHA_SECRET_KEY | Kunci rahasia reCAPTCHA | kosong |
BEHIND_REVERSE_PROXY | Di belakang reverse proxy | false |
SSL_MODE | Mode SSL (none, letsencrypt, manual) | none |
SSL_DOMAIN | Domain untuk SSL | kosong |
ILDIS_IMAGE_TAG | Tag image Docker | latest |
Environment Production
Section titled “Environment Production”Pastikan environment variable berikut dikonfigurasi dengan benar untuk production:
| Variabel | Nilai Production | Keterangan |
|---|---|---|
YII_ENV | prod | Menonaktifkan debug mode |
YII_DEBUG | false | Menyembunyikan error detail dari pengguna |
DB_HOST | Host database | Bukan localhost jika database terpisah |
DB_PASSWORD | Password kuat | Gunakan password yang aman dan unik |
Reverse Proxy
Section titled “Reverse Proxy”ILDIS dapat dijalankan di belakang reverse proxy (Nginx, Apache, atau Traefik). Berikut contoh konfigurasi untuk masing-masing:
server { set $project_root /path/to/ildis.go.id; #set $fcgi_server 127.0.0.1:9000; set $fcgi_server unix:/var/run/php-fpm/example.socket;
charset utf-8; client_max_body_size 128M;
listen 80;
server_name ildis.go.id; root $project_root/; index index.php;
access_log /var/log/nginx/ildis.access.log combined; error_log /var/log/nginx/ildis.error.log warn;
location ^~ /backend { rewrite ^/backend(.*)$ /backend/$1 last; }
location ^~ /backend/ { root $project_root;
# uncomment the following, if you want to enable speaking URL in the backend #try_files $uri $uri/ /backend/index.php$is_args$args;
location ~ /\.(ht|svn|git) { deny all; }
location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass $fcgi_server; try_files $uri =404; } }
location / { try_files $uri $uri/ /index.php$is_args$args; }
location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|woff2?|ttf|svg|eot|webp|pdf)$ { expires 30d; access_log off; add_header Cache-Control "public"; try_files $uri =404; }
location ~ /\.(ht|svn|git|env|DS_Store) { deny all; }
location ~ ^/(vendor|node_modules|\.vagrant|vagrant|DATABASE|\.github)(/|$) { deny all; return 403; }
location ~* ^/(Vagrantfile|composer\.(json|lock|phar)|package\.json|\.bowerrc|\.gitignore|README.*|CHANGE.*|codeception\.yml|requirements\.php|yii(_test)?(\.bat)?)$ { deny all; return 403; }
location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass $fcgi_server; try_files $uri =404; }}Aktifkan konfigurasi:
sudo ln -s /etc/nginx/sites-available/ildis /etc/nginx/sites-enabled/sudo nginx -tsudo systemctl reload nginx<VirtualHost *:80> #ganti dengan domain anda ServerName ildis-demo.bphn.go.id
#ErrorLog /var/log/apache2/advanced.local.error.log #CustomLog /var/log/apache2/advanced.local.access.log combined AddDefaultCharset UTF-8
Options FollowSymLinks DirectoryIndex index.php index.html RewriteEngine on
RewriteRule /\. - [L,F]
DocumentRoot /var/www/ildis/ <Directory /var/www/ildis/> AllowOverride none <IfVersion < 2.4> Order Allow,Deny Allow from all </IfVersion> <IfVersion >= 2.4> Require all granted </IfVersion>
# if a directory or a file exists, use the request directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward the request to index.php RewriteRule ^ index.php [L] </Directory>
# redirect to the URL without a trailing slash (uncomment if necessary) #RewriteRule ^/admin/$ /admin [L,R=301]
Alias /admin /var/www/ildis/backend/ # prevent the directory redirect to the URL with a trailing slash RewriteRule ^/admin$ /admin/ [L,PT] <Directory /var/www/ildis/backend/> AllowOverride none <IfVersion < 2.4> Order Allow,Deny Allow from all </IfVersion> <IfVersion >= 2.4> Require all granted </IfVersion>
# if a directory or a file exists, use the request directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward the request to index.php RewriteRule ^ index.php [L] </Directory></VirtualHost>Aktifkan konfigurasi:
sudo a2ensite ildissudo apache2ctl configtestsudo systemctl reload apache2Jika Anda menggunakan metode Pasang Cepat dan memilih tanpa reverse proxy, script instalasi akan menyiapkan Traefik secara otomatis.
Untuk konfigurasi manual, lihat file traefik/traefik.yml dan traefik/config.yml yang dibuat oleh script instalasi.
SSL/TLS
Section titled “SSL/TLS”Let’s Encrypt (Direkomendasikan)
Section titled “Let’s Encrypt (Direkomendasikan)”Jika server Anda memiliki domain publik, gunakan Let’s Encrypt untuk sertifikat SSL gratis:
- Metode Pasang Cepat: Pilih opsi SSL “Let’s Encrypt” saat instalasi interaktif. Script akan mengkonfigurasi Traefik secara otomatis.
- Metode Manual: Gunakan Certbot dengan Nginx atau Apache.
sudo certbot --nginx -d ildis.example.comSertifikat Manual
Section titled “Sertifikat Manual”Jika Anda memiliki sertifikat SSL sendiri:
- Metode Pasang Cepat: Pilih opsi SSL “Manual” dan masukkan path ke sertifikat dan kunci privat Anda.
- Metode Manual: Konfigurasi sertifikat langsung di virtual host Nginx atau Apache.
Database Backup & Restore
Section titled “Database Backup & Restore”Backup
Section titled “Backup”Buat backup database secara berkala menggunakan mysqldump:
mysqldump -u ildis -p ildis_v4 > ildis_v4_backup_$(date +%Y%m%d).sqlUntuk backup otomatis, tambahkan ke cron:
0 2 * * * mysqldump -u ildis -p ildis_v4 | gzip > /backups/ildis_v4_$(date +%Y%m%d).sql.gzRestore
Section titled “Restore”Untuk mengembalikan database dari backup:
gunzip < /backups/ildis_v4_20250101.sql.gz | mysql -u ildis -p ildis_v4Memperbarui ILDIS di Production
Section titled “Memperbarui ILDIS di Production”Metode Pasang Cepat (Docker/Podman)
Section titled “Metode Pasang Cepat (Docker/Podman)”Jika Anda menginstal ILDIS menggunakan script Pasang Cepat:
./install.sh --updateScript akan:
- Membuat backup konfigurasi
.envdandocker-compose.yml - Menarik image terbaru dari GitHub Container Registry
- Menjalankan migrasi database (
php yii migrate/up) - Memulai ulang container
Metode Manual
Section titled “Metode Manual”Untuk instalasi manual di production:
cd /var/www/ildisgit pull origin maincomposer install --ignore-platform-reqsphp yii migrate/up --interactive=0Security Checklist
Section titled “Security Checklist”Sebelum men-deploy ILDIS ke production, pastikan item berikut sudah dikonfigurasi:
-
YII_ENV=proddanYII_DEBUG=falsedi.env -
COOKIE_VALIDATION_KEY_BEdanCOOKIE_VALIDATION_KEY_FEdiisi dengan kunci yang kuat -
RECAPTCHA_ENABLED=truepada halaman login backend (opsional tapi direkomendasikan) - SSL/TLS diaktifkan (Let’s Encrypt atau sertifikat manual)
- File
.envtidak dapat diakses publik (tidak terexpose oleh web server) - Database menggunakan password yang kuat
- Port database tidak diekspos ke publik kecuali diperlukan
- Backup database dijadwalkan secara berkala
- Log rotation dikonfigurasi untuk mencegah disk penuh
Bantuan dan Dukungan
Section titled “Bantuan dan Dukungan”Jika Anda mengalami masalah saat deployment:
- Periksa log container:
docker compose -f /opt/ildis/docker-compose.yml logs(metode Docker) - Periksa log aplikasi:
tail -f /var/www/ildis/runtime/logs/*.log(metode manual) - Hubungi tim IT di it.dev@bphn.go.id