Skip to content

Commit ed7fd37

Browse files
committed
fix: setting error.
1 parent 43dcfba commit ed7fd37

6 files changed

Lines changed: 40 additions & 16 deletions

File tree

.env.example

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ COOKIE_SECURE=false # Set to true in production with HTTPS
1515
# Extra origins allowed for CSRF/CORS (comma-separated). localhost:5173 and
1616
# localhost:3000 are always allowed. Set your public URL here in prod.
1717
ALLOWED_ORIGINS=
18-
19-
# ── Frontend ──
20-
VITE_API_URL=http://localhost:8000
18+
# Trust X-Forwarded-For from a reverse proxy when computing rate-limit keys.
19+
# The shipped docker-compose runs nginx in front of the backend and sets this
20+
# to true via the compose env block; only enable here if you put a different
21+
# trusted proxy in front. Leaving this off behind a proxy collapses every
22+
# client to the proxy's IP.
23+
TRUST_PROXY=false
2124

2225
# ── AI Chat (optional) ──
2326
# Defaults target Gemini. Get an API key at https://aistudio.google.com/apikey
2427
# Any OpenAI-compatible provider works — just change AI_BASE_URL + AI_MODEL.
2528
AI_ENABLED=false
2629
AI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai
2730
AI_API_KEY=
28-
AI_MODEL=gemini-2.5-flash
31+
AI_MODEL=gemini-2.0-flash
2932
AI_MAX_CONTEXT_PAGES=5
3033
AI_EXCERPT_CHARS=1500
3134
AI_RATE_LIMIT_PER_HOUR=20
@@ -37,7 +40,8 @@ AI_RATE_LIMIT_PER_HOUR=20
3740

3841
# ── OIDC / OAuth SSO (optional) ──
3942
# Public URL the browser can reach — used to build OIDC redirect_uri.
40-
# Dev with Vite proxy: http://localhost:5173 Prod: https://wiki.example.com
43+
# Dev with Vite proxy: http://localhost:5173 Docker: http://localhost:3000
44+
# (compose overrides this automatically) Prod: https://wiki.example.com
4145
PUBLIC_BASE_URL=http://localhost:8000
4246

4347
OIDC_ENABLED=false
@@ -90,6 +94,3 @@ LDAP_SYNC_GROUPS=false
9094
LDAP_GROUP_BASE=ou=groups,dc=example,dc=com
9195
LDAP_GROUP_FILTER=(&(objectClass=groupOfNames)(member={user_dn}))
9296
LDAP_ADMIN_GROUPS=wiki-admins
93-
94-
# ── Webhook (Phase 7, 可選) ──
95-
WEBHOOK_URLS=

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ jobs:
159159
echo "skip=false" >> $GITHUB_OUTPUT
160160
fi
161161
162+
- name: Set up QEMU
163+
if: steps.check.outputs.skip != 'true'
164+
uses: docker/setup-qemu-action@v3
165+
162166
- name: Set up Docker Buildx
163167
if: steps.check.outputs.skip != 'true'
164168
uses: docker/setup-buildx-action@v3
@@ -190,6 +194,7 @@ jobs:
190194
context: .
191195
file: ./${{ matrix.component }}/Dockerfile
192196
push: true
197+
platforms: linux/amd64,linux/arm64
193198
tags: ${{ steps.meta.outputs.tags }}
194199
labels: ${{ steps.meta.outputs.labels }}
195200
cache-from: type=gha

backend/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ COPY backend/ .
1717
COPY VERSION /app/VERSION
1818

1919
EXPOSE 8000
20+
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
21+
CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/api/health',timeout=3).status==200 else 1)" || exit 1
2022
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

backend/app/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class Settings(BaseSettings):
1515
DB_PATH: str = "./data/just-wiki.db"
1616
MEDIA_DIR: str = "./data/media"
1717

18-
VITE_API_URL: str = "http://localhost:8000"
1918
COOKIE_SECURE: bool = False # Set to True in production with HTTPS
2019

2120
# Comma-separated list of origins allowed for CSRF/CORS on top of the
@@ -110,9 +109,13 @@ class Settings(BaseSettings):
110109
# one directory up (so `make dev-backend`, which cds into backend/, still
111110
# picks up the project-root .env). pydantic-settings uses the first file
112111
# that exists.
112+
#
113+
# extra='ignore' so renaming/removing a setting doesn't crash on existing
114+
# deployments where the user's .env still has the old key.
113115
model_config = {
114116
"env_file": (".env", "../.env"),
115117
"env_file_encoding": "utf-8",
118+
"extra": "ignore",
116119
}
117120

118121

docker-compose.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@ services:
44
build:
55
context: .
66
dockerfile: backend/Dockerfile
7-
ports:
8-
- "8000:8000"
97
volumes:
108
- ./data:/app/data
11-
env_file: .env
12-
# Override the dev-oriented paths in .env so the container reads/writes
13-
# the mounted /app/data volume regardless of what DATA_DIR is set to in
14-
# the shared .env file.
9+
env_file:
10+
- path: .env
11+
required: false
12+
# Override the dev-oriented defaults so the container reads/writes the
13+
# mounted /app/data volume and treats the frontend nginx (port 3000) as
14+
# the public ingress — OIDC redirect_uri must round-trip through nginx.
15+
# TRUST_PROXY=true because nginx is the only reachable peer.
1516
environment:
1617
DATA_DIR: /app/data
1718
DB_PATH: /app/data/just-wiki.db
1819
MEDIA_DIR: /app/data/media
20+
PUBLIC_BASE_URL: ${PUBLIC_BASE_URL:-http://localhost:3000}
21+
TRUST_PROXY: "true"
22+
healthcheck:
23+
test: ["CMD", "python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/api/health',timeout=3).status==200 else 1)"]
24+
interval: 30s
25+
timeout: 5s
26+
start_period: 15s
27+
retries: 3
1928
restart: unless-stopped
2029

2130
frontend:
@@ -26,5 +35,6 @@ services:
2635
ports:
2736
- "3000:3000"
2837
depends_on:
29-
- backend
38+
backend:
39+
condition: service_healthy
3040
restart: unless-stopped

frontend/nginx.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ server {
77
proxy_pass http://backend:8000;
88
proxy_set_header Host $host;
99
proxy_set_header X-Real-IP $remote_addr;
10+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
11+
proxy_set_header X-Forwarded-Proto $scheme;
12+
proxy_set_header X-Forwarded-Host $host;
1013
}
1114

1215
location / {

0 commit comments

Comments
 (0)