Self-Hosting Guide
Requirements
- Docker
- Node.js 20+
- npm
- 通过 bundled Docker setup 提供的 PostgreSQL 16+
Quick Start
git clone https://github.com/kirill-markin/flashcards-open-source-app.git
cd flashcards-open-source-app
cp .env.example .env
make db-up
npm install --prefix api
npm install --prefix apps/auth
npm install --prefix apps/backend
npm install --prefix apps/web
然后在不同 terminal windows 中启动 services:
make auth-dev
make backend-dev
make web-dev
会启动:
postgreson port5432authon port8081backendon port8080webon port3000
Local addresses:
http://localhost:3000for the web apphttp://localhost:8080/v1for the backend APIhttp://localhost:8081for the auth service
Configuration
将 .env.example 复制为 .env,并设置以下值:
DATABASE_URL— Postgres connection stringAUTH_MODE— 本地使用none,email OTP auth 使用cognitoBACKEND_ALLOWED_ORIGINS— session-backed API requests 的 allowed originsPUBLIC_API_BASE_URL和PUBLIC_AUTH_BASE_URL— 如果你希望在 discovery responses 中返回自定义 public hosts,可使用 optional overrides
Local iOS Setup
主 repository 中的 iOS app 会从这里读取 local API 与 auth hosts:
apps/ios/Flashcards/Config/Local.xcconfig
如有需要,复制 example file:
cp apps/ios/Flashcards/Config/Local.xcconfig.example apps/ios/Flashcards/Config/Local.xcconfig
然后将其指向你本地或 self-hosted 的 api 与 auth domains。
Updating
git pull
npm install --prefix api
npm install --prefix apps/auth
npm install --prefix apps/backend
npm install --prefix apps/web
Dependency changes 后请重启 local services。
AWS Deployment
Documented production shape:
- CloudFront + S3 for
app.<domain> - API Gateway + Lambda for
api.<domain> - API Gateway + Lambda for
auth.<domain> - Postgres on AWS RDS
- Cognito for passwordless email auth
- Optional apex redirect when the root domain is unused
详情请见: