Refactor code structure for improved readability and maintainability
This commit is contained in:
parent
f8d64e4e7d
commit
66f592ee2e
6 changed files with 19 additions and 14 deletions
|
|
@ -89,8 +89,8 @@ docker compose up -d
|
||||||
| บริการ | URL | เข้าด้วย |
|
| บริการ | URL | เข้าด้วย |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Keycloak admin console | https://localhost:8443/admin/ | `KC_BOOTSTRAP_ADMIN_USERNAME` / `KC_BOOTSTRAP_ADMIN_PASSWORD` จาก `.env` |
|
| Keycloak admin console | https://localhost:8443/admin/ | `KC_BOOTSTRAP_ADMIN_USERNAME` / `KC_BOOTSTRAP_ADMIN_PASSWORD` จาก `.env` |
|
||||||
| MinIO console | http://localhost:9001 | `MINIO_ROOT_USER` / `MINIO_ROOT_PASSWORD` จาก `.env` |
|
| MinIO console | http://localhost:39001 | `MINIO_ROOT_USER` / `MINIO_ROOT_PASSWORD` จาก `.env` |
|
||||||
| PostgreSQL | `localhost:5432` | `POSTGRES_USER` / `POSTGRES_PASSWORD` จาก `.env`, ฐานข้อมูล `wordversioning` |
|
| PostgreSQL | `localhost:35432` | `POSTGRES_USER` / `POSTGRES_PASSWORD` จาก `.env`, ฐานข้อมูล `wordversioning` |
|
||||||
|
|
||||||
> **ทำไม Keycloak ต้องเป็น HTTPS:** Office Dialog API ที่ add-in ใช้เปิดหน้า login **ปฏิเสธ http:// โดยสมบูรณ์** (error: "The HTTP protocol is not supported. Use HTTPS instead") — dev จึงให้ Keycloak เสิร์ฟ HTTPS ที่ port 8443 ด้วย cert ของ `office-addin-dev-certs` (CA ถูก trust ในเครื่องแล้ว Word/webview จึงเชื่อ) · ตัว issuer ใน token จะเป็น `https://localhost:8443/realms/word-versioning` ซึ่ง backend ตั้ง `Authentication:Authority` ตรงกัน
|
> **ทำไม Keycloak ต้องเป็น HTTPS:** Office Dialog API ที่ add-in ใช้เปิดหน้า login **ปฏิเสธ http:// โดยสมบูรณ์** (error: "The HTTP protocol is not supported. Use HTTPS instead") — dev จึงให้ Keycloak เสิร์ฟ HTTPS ที่ port 8443 ด้วย cert ของ `office-addin-dev-certs` (CA ถูก trust ในเครื่องแล้ว Word/webview จึงเชื่อ) · ตัว issuer ใน token จะเป็น `https://localhost:8443/realms/word-versioning` ซึ่ง backend ตั้ง `Authentication:Authority` ตรงกัน
|
||||||
|
|
||||||
|
|
|
||||||
BIN
T14_Template.docx
Normal file
BIN
T14_Template.docx
Normal file
Binary file not shown.
|
|
@ -6,8 +6,8 @@ public class MinioOptions
|
||||||
{
|
{
|
||||||
public const string SectionName = "MinIO";
|
public const string SectionName = "MinIO";
|
||||||
|
|
||||||
/// <summary>host:port ไม่รวม scheme (เช่น localhost:9000 หรือ minio:9000)</summary>
|
/// <summary>host:port ไม่รวม scheme (เช่น localhost:39000 หรือ minio:9000)</summary>
|
||||||
public string Endpoint { get; set; } = "localhost:9000";
|
public string Endpoint { get; set; } = "localhost:39000";
|
||||||
|
|
||||||
public string AccessKey { get; set; } = string.Empty;
|
public string AccessKey { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"//": "ค่า local dev ตรงกับ .env.example (docker compose) — ถ้าจะ override ด้วย env ใช้ตัวแปร เช่น MinIO__Endpoint, ConnectionStrings__Default, Authentication__Authority",
|
"//": "ค่า local dev ตรงกับ .env.example (docker compose) — ถ้าจะ override ด้วย env ใช้ตัวแปร เช่น MinIO__Endpoint, ConnectionStrings__Default, Authentication__Authority",
|
||||||
|
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Default": "Host=localhost;Port=5432;Database=wordversioning;Username=wordversioning;Password=dev-local-pass"
|
"Default": "Host=localhost;Port=35432;Database=wordversioning;Username=wordversioning;Password=dev-local-pass"
|
||||||
},
|
},
|
||||||
|
|
||||||
"MinIO": {
|
"MinIO": {
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
|
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Default": "Host=localhost;Port=5432;Database=wordversioning;Username=wordversioning;Password="
|
"Default": "Host=localhost;Port=35432;Database=wordversioning;Username=wordversioning;Password="
|
||||||
},
|
},
|
||||||
|
|
||||||
"MinIO": {
|
"MinIO": {
|
||||||
"Endpoint": "localhost:9000",
|
"Endpoint": "localhost:39000",
|
||||||
"AccessKey": "",
|
"AccessKey": "",
|
||||||
"SecretKey": "",
|
"SecretKey": "",
|
||||||
"UseSSL": false,
|
"UseSSL": false,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ services:
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432" # เปิดให้ backend ที่รันด้วย dotnet run บน host เชื่อมได้
|
- "35432:5432" # เปิดให้ backend ที่รันด้วย dotnet run บน host เชื่อมได้ (host 35432 → container 5432)
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|
@ -25,17 +25,22 @@ services:
|
||||||
retries: 12
|
retries: 12
|
||||||
|
|
||||||
# --- MinIO (S3-compatible สำหรับไฟล์ .docx) -----------------------
|
# --- MinIO (S3-compatible สำหรับไฟล์ .docx) -----------------------
|
||||||
|
# container listen 39000/39001 เท่ากับ host ตรงๆ (ไม่ map ข้าม port) — map ข้ามแล้ว
|
||||||
|
# console จะ redirect/-เชื่อม server ผิด port (login error / เด้งไป :9001 ตาย)
|
||||||
minio:
|
minio:
|
||||||
image: minio/minio:latest
|
image: minio/minio:latest
|
||||||
command: server /data --console-address ":9001"
|
command: server /data --address ":39000" --console-address ":39001"
|
||||||
environment:
|
environment:
|
||||||
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
|
||||||
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
||||||
# ให้ healthcheck (mc ready) เรียกผ่าน alias "local" ได้
|
# ให้ healthcheck (mc ready) เรียกผ่าน alias "local" ได้
|
||||||
MC_HOST_local: http://${MINIO_ROOT_USER}:${MINIO_ROOT_PASSWORD}@localhost:9000
|
MC_HOST_local: http://${MINIO_ROOT_USER}:${MINIO_ROOT_PASSWORD}@localhost:39000
|
||||||
|
# URL ภายนอกที่ browser เห็น — ตรงกับ port จริงที่ listen จึงใช้ได้ทั้งใน/นอก container
|
||||||
|
MINIO_BROWSER_REDIRECT_URL: http://localhost:39001
|
||||||
|
MINIO_SERVER_URL: http://localhost:39000
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000" # S3 API
|
- "39000:39000" # S3 API
|
||||||
- "9001:9001" # MinIO console
|
- "39001:39001" # MinIO console
|
||||||
volumes:
|
volumes:
|
||||||
- minio_data:/data
|
- minio_data:/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|
@ -58,7 +63,7 @@ services:
|
||||||
entrypoint: >
|
entrypoint: >
|
||||||
/bin/sh -c "
|
/bin/sh -c "
|
||||||
set -e;
|
set -e;
|
||||||
mc alias set local http://minio:9000 $$MINIO_ROOT_USER $$MINIO_ROOT_PASSWORD;
|
mc alias set local http://minio:39000 $$MINIO_ROOT_USER $$MINIO_ROOT_PASSWORD;
|
||||||
mc mb --ignore-existing local/docx-versions;
|
mc mb --ignore-existing local/docx-versions;
|
||||||
mc mb --ignore-existing local/docx-templates;
|
mc mb --ignore-existing local/docx-templates;
|
||||||
mc anonymous set none local/docx-versions;
|
mc anonymous set none local/docx-versions;
|
||||||
|
|
@ -89,7 +94,7 @@ services:
|
||||||
- ${HOME}/.office-addin-dev-certs:/certs:ro
|
- ${HOME}/.office-addin-dev-certs:/certs:ro
|
||||||
|
|
||||||
# --- Backend API (ยังไม่เปิดใช้ — รอ Phase 2 สร้าง Dockerfile) -----
|
# --- Backend API (ยังไม่เปิดใช้ — รอ Phase 2 สร้าง Dockerfile) -----
|
||||||
# รันฝั่ง host ด้วย `dotnet run` ได้เลย โดยชี้ config ไปที่ localhost:5432 / localhost:9000
|
# รันฝั่ง host ด้วย `dotnet run` ได้เลย โดยชี้ config ไปที่ localhost:5432 / localhost:39000
|
||||||
# หรือรันใน network นี้: docker compose --profile api up -d --build
|
# หรือรันใน network นี้: docker compose --profile api up -d --build
|
||||||
api:
|
api:
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue