Adjust compose ports for Coolify deployment

This commit is contained in:
2026-06-10 20:35:08 +07:00
parent c0aa8e09d5
commit c22c9c8c84
4 changed files with 47 additions and 12 deletions
+26 -6
View File
@@ -7,6 +7,7 @@ File Docker sudah disiapkan, tetapi belum dijalankan.
```text
Dockerfile
docker-compose.yml
docker-compose.local.yml
.env.example
.dockerignore
docker/mysql-init/99-grants.sql
@@ -20,13 +21,24 @@ Membuat image aplikasi PHP Apache. File ini memasang extension PHP yang dibutuhk
`docker-compose.yml`
Mengatur dua service:
Mengatur dua service untuk deploy:
```text
app = Apache + PHP + semua file project
db = MySQL 8.0
```
File ini tidak membuka port host secara langsung supaya aman dipakai di server/Coolify dan tidak bentrok dengan aplikasi lain.
`docker-compose.local.yml`
File tambahan khusus saat menjalankan di laptop. File ini membuka:
```text
APP_PORT=8080 -> app port 80
DB_PORT=3307 -> db port 3306
```
`.env.example`
Template konfigurasi port, username, password, dan nama database. File ini boleh masuk Git karena tidak berisi password production.
@@ -67,7 +79,7 @@ MYSQL_ROOT_PASSWORD=root_password
3. Build dan jalankan container:
```bash
docker compose up -d --build
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d --build
```
4. Buka aplikasi:
@@ -82,23 +94,29 @@ http://localhost:8080
docker compose ps
```
atau jika ingin melihat compose lokal:
```bash
docker compose -f docker-compose.yml -f docker-compose.local.yml ps
```
6. Lihat log jika ada error:
```bash
docker compose logs -f
docker compose -f docker-compose.yml -f docker-compose.local.yml logs -f
```
7. Matikan container:
```bash
docker compose down
docker compose -f docker-compose.yml -f docker-compose.local.yml down
```
8. Reset database Docker dari awal:
```bash
docker compose down -v
docker compose up -d --build
docker compose -f docker-compose.yml -f docker-compose.local.yml down -v
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d --build
```
## Catatan Penting
@@ -110,3 +128,5 @@ docker/mysql-init/99-grants.sql
```
Untuk production, ganti semua password default di `.env`.
Saat deploy di Coolify, cukup gunakan `docker-compose.yml`. Jangan publish port `8080` dari compose utama karena port itu bisa sudah dipakai aplikasi lain di server.
+11 -2
View File
@@ -24,7 +24,8 @@ Landingpage/
| |-- assets/
| `-- sql/
|-- Dockerfile # Persiapan Docker, belum perlu dijalankan
|-- docker-compose.yml # Persiapan service app + database
|-- docker-compose.yml # Service app + database untuk deploy
|-- docker-compose.local.yml # Override port untuk menjalankan lokal
|-- .env.example # Contoh konfigurasi environment
|-- .dockerignore
|-- .gitignore
@@ -105,12 +106,20 @@ Password: admin123
## Docker
File Docker sudah disiapkan untuk dipelajari, tetapi belum dijalankan. Baca:
File Docker sudah disiapkan untuk lokal dan deploy. Baca:
```text
DOCKER_STEPS.md
```
Untuk menjalankan lokal dengan akses `http://localhost:8080`, gunakan:
```bash
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d --build
```
Untuk deploy di Coolify, gunakan `docker-compose.yml` saja agar port host tidak bentrok dengan aplikasi lain di server.
## Catatan Git
File yang tidak perlu masuk Git sudah dicatat di `.gitignore`, terutama `.env`, upload, log, `vendor`, dan `node_modules`.
+8
View File
@@ -0,0 +1,8 @@
services:
app:
ports:
- "${APP_PORT:-8080}:80"
db:
ports:
- "${DB_PORT:-3307}:3306"
+2 -4
View File
@@ -3,8 +3,8 @@ services:
build: .
container_name: webgis-portal-app
restart: unless-stopped
ports:
- "${APP_PORT:-8080}:80"
expose:
- "80"
environment:
DB_HOST: ${DB_HOST:-db}
DB_DATABASE: ${DB_DATABASE:-webgis_miskin}
@@ -30,8 +30,6 @@ services:
MYSQL_DATABASE: ${DB_DATABASE:-webgis_miskin}
MYSQL_USER: ${DB_USERNAME:-webgis_user}
MYSQL_PASSWORD: ${DB_PASSWORD:-webgis_password}
ports:
- "${DB_PORT:-3307}:3306"
volumes:
- db_data:/var/lib/mysql
- ./Leaflet/sql/schema.sql:/docker-entrypoint-initdb.d/01-spbu-schema.sql:ro