Initial WebGIS portal project
This commit is contained in:
+112
@@ -0,0 +1,112 @@
|
||||
# Langkah Belajar Docker
|
||||
|
||||
File Docker sudah disiapkan, tetapi belum dijalankan.
|
||||
|
||||
## File yang Dibuat
|
||||
|
||||
```text
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
.env.example
|
||||
.dockerignore
|
||||
docker/mysql-init/99-grants.sql
|
||||
```
|
||||
|
||||
## Fungsi Setiap File
|
||||
|
||||
`Dockerfile`
|
||||
|
||||
Membuat image aplikasi PHP Apache. File ini memasang extension PHP yang dibutuhkan project, seperti `pdo_mysql`, `mysqli`, dan `curl`.
|
||||
|
||||
`docker-compose.yml`
|
||||
|
||||
Mengatur dua service:
|
||||
|
||||
```text
|
||||
app = Apache + PHP + semua file project
|
||||
db = MySQL 8.0
|
||||
```
|
||||
|
||||
`.env.example`
|
||||
|
||||
Template konfigurasi port, username, password, dan nama database. File ini boleh masuk Git karena tidak berisi password production.
|
||||
|
||||
`.dockerignore`
|
||||
|
||||
Mengatur file/folder yang tidak perlu ikut masuk image Docker, seperti `.git`, `.env`, upload, log, `vendor`, dan `node_modules`.
|
||||
|
||||
`docker/mysql-init/99-grants.sql`
|
||||
|
||||
Memberi akses user `webgis_user` ke dua database:
|
||||
|
||||
```text
|
||||
webgis_spbu
|
||||
webgis_miskin
|
||||
```
|
||||
|
||||
## Urutan Menjalankan Nanti
|
||||
|
||||
Jangan jalankan dulu kalau masih belajar struktur. Saat sudah siap, urutannya:
|
||||
|
||||
1. Salin file environment:
|
||||
|
||||
```bash
|
||||
copy .env.example .env
|
||||
```
|
||||
|
||||
2. Buka `.env`, lalu pelajari nilai berikut:
|
||||
|
||||
```text
|
||||
APP_PORT=8080
|
||||
DB_PORT=3307
|
||||
DB_USERNAME=webgis_user
|
||||
DB_PASSWORD=webgis_password
|
||||
MYSQL_ROOT_PASSWORD=root_password
|
||||
```
|
||||
|
||||
3. Build dan jalankan container:
|
||||
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
4. Buka aplikasi:
|
||||
|
||||
```text
|
||||
http://localhost:8080
|
||||
```
|
||||
|
||||
5. Cek container:
|
||||
|
||||
```bash
|
||||
docker compose ps
|
||||
```
|
||||
|
||||
6. Lihat log jika ada error:
|
||||
|
||||
```bash
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
7. Matikan container:
|
||||
|
||||
```bash
|
||||
docker compose down
|
||||
```
|
||||
|
||||
8. Reset database Docker dari awal:
|
||||
|
||||
```bash
|
||||
docker compose down -v
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
## Catatan Penting
|
||||
|
||||
Kalau kamu mengubah `DB_USERNAME` di `.env`, sesuaikan juga isi:
|
||||
|
||||
```text
|
||||
docker/mysql-init/99-grants.sql
|
||||
```
|
||||
|
||||
Untuk production, ganti semua password default di `.env`.
|
||||
Reference in New Issue
Block a user