diff --git a/Dockerfile b/Dockerfile index 2cb588f..8a0c36d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,6 @@ RUN pip install --no-cache-dir -r requirements.txt COPY app ./app RUN useradd -r -u 10001 coremarket && mkdir -p /data && chown coremarket /data USER coremarket -EXPOSE 8080 -HEALTHCHECK CMD python -c "import urllib.request;urllib.request.urlopen('http://127.0.0.1:8080/healthz')" -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"] +EXPOSE 8999 +HEALTHCHECK CMD python -c "import urllib.request;urllib.request.urlopen('http://127.0.0.1:8999/healthz')" +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8999"] diff --git a/README.md b/README.md index 36e6ed8..4fddf97 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ PCI DSS / GDPR status and estimated latency to 40 cities. ```bash cp .env.example .env # then set ADMIN_USERNAME and ADMIN_PASSWORD (at least 10 characters) docker compose up -d --build -open http://localhost:8080 # sign in as the admin +open http://localhost:8999 # sign in as the admin ``` On first run, Coremarket creates the admin account from `ADMIN_USERNAME` / `ADMIN_PASSWORD`. If no @@ -86,13 +86,13 @@ In the web page, the account menu (your username, top right) has **API keys**, * Coremarket has a JSON REST API. The web page uses the same API. -- **Base URL:** `http://localhost:8080/api/v1` +- **Base URL:** `http://localhost:8999/api/v1` - **Authentication:** every call needs an API key in the `X-API-Key` header (or `Authorization: Bearer `). Create keys under **Account → API keys**. See [Authentication](#authentication). -- **Interactive docs:** `http://localhost:8080/docs` (Swagger UI, where you can try every call; sign in - first). There's also `http://localhost:8080/redoc`. -- **OpenAPI spec:** `http://localhost:8080/openapi.json` (for generating client code; needs a key or +- **Interactive docs:** `http://localhost:8999/docs` (Swagger UI, where you can try every call; sign in + first). There's also `http://localhost:8999/redoc`. +- **OpenAPI spec:** `http://localhost:8999/openapi.json` (for generating client code; needs a key or sign-in) - **Prices** are USD per month unless a field says otherwise. Latencies are estimated round-trip times in milliseconds. @@ -105,17 +105,17 @@ alias cm='curl -s -H "X-API-Key: $KEY"' # Cheapest GDPR-compliant European option per provider for the Good tier, # with average/worst latency to Paris and Berlin -cm "http://localhost:8080/api/v1/quote?tier=good&continent=europe&compliance=gdpr&cities=par,ber&best_per_provider=true&limit=5" +cm "http://localhost:8999/api/v1/quote?tier=good&continent=europe&compliance=gdpr&cities=par,ber&best_per_provider=true&limit=5" # HIPAA-eligible options for the Best tier, closest to Bogota and Lima first -cm "http://localhost:8080/api/v1/quote?tier=best&compliance=hipaa&cities=bog,lim&sort=rtt_max_ms&limit=5" +cm "http://localhost:8999/api/v1/quote?tier=best&compliance=hipaa&cities=bog,lim&sort=rtt_max_ms&limit=5" # Just the VM size for Base plus Vaultwarden, 20 concurrent users -cm -X POST http://localhost:8080/api/v1/size -H 'Content-Type: application/json' \ +cm -X POST http://localhost:8999/api/v1/size -H 'Content-Type: application/json' \ -d '{"tier": "base", "apps": ["vaultwarden"], "concurrent": 20}' # Every option as a spreadsheet (one column per city latency) -cm -o quote.csv "http://localhost:8080/api/v1/quote?tier=better&format=csv" +cm -o quote.csv "http://localhost:8999/api/v1/quote?tier=better&format=csv" ``` ### Endpoints @@ -161,22 +161,22 @@ Health check: `GET /healthz` (outside `/api/v1`, no sign-in). ```bash # Admin: create an account, then a 90-day key for it -cm -X POST http://localhost:8080/api/v1/users -H 'Content-Type: application/json' \ +cm -X POST http://localhost:8999/api/v1/users -H 'Content-Type: application/json' \ -d '{"username": "alice", "password": "a-long-password", "role": "user"}' # -> {"id": 2, "username": "alice", "role": "user", "disabled": false, ...} -cm -X POST http://localhost:8080/api/v1/keys -H 'Content-Type: application/json' \ +cm -X POST http://localhost:8999/api/v1/keys -H 'Content-Type: application/json' \ -d '{"name": "alice reporting", "expires_days": 90, "user_id": 2}' # -> {"key": "cmk_1a2b3c4d_...", "id": 5, "prefix": "cmk_1a2b3c4d_…", "username": "alice", "expires_at": ..., "warning": "..."} # Disable, re-enable, or delete the account -cm -X PATCH http://localhost:8080/api/v1/users/2 -H 'Content-Type: application/json' -d '{"disabled": true}' -cm -X PATCH http://localhost:8080/api/v1/users/2 -H 'Content-Type: application/json' -d '{"disabled": false}' -cm -X DELETE http://localhost:8080/api/v1/users/2 +cm -X PATCH http://localhost:8999/api/v1/users/2 -H 'Content-Type: application/json' -d '{"disabled": true}' +cm -X PATCH http://localhost:8999/api/v1/users/2 -H 'Content-Type: application/json' -d '{"disabled": false}' +cm -X DELETE http://localhost:8999/api/v1/users/2 # Any user: list and revoke your own keys -cm http://localhost:8080/api/v1/keys -cm -X DELETE http://localhost:8080/api/v1/keys/5 +cm http://localhost:8999/api/v1/keys +cm -X DELETE http://localhost:8999/api/v1/keys/5 ``` ### Sizing and quote parameters @@ -256,10 +256,10 @@ Contabo has no pricing API, so its prices live in an editable sheet: ```bash # Read the current sheet -cm http://localhost:8080/api/v1/providers/contabo/price-sheet +cm http://localhost:8999/api/v1/providers/contabo/price-sheet # Replace it (admin; prices in the sheet's currency, per month; surcharge is % per region code) -cm -X PUT http://localhost:8080/api/v1/providers/contabo/price-sheet -H 'Content-Type: application/json' \ +cm -X PUT http://localhost:8999/api/v1/providers/contabo/price-sheet -H 'Content-Type: application/json' \ -d '{ "currency": "EUR", "fx": 1.16, "setup_fee": 2.00, "plans": [ @@ -270,7 +270,7 @@ cm -X PUT http://localhost:8080/api/v1/providers/contabo/price-sheet -H 'Content }' # Go back to the built-in sheet -cm -X DELETE http://localhost:8080/api/v1/providers/contabo/price-sheet +cm -X DELETE http://localhost:8999/api/v1/providers/contabo/price-sheet ``` Plan fields: `name`, `vcpu`, `ram_gb` and `price` are required. `code`, `disk_gb`, `cpu_type` @@ -279,7 +279,7 @@ Plan fields: `name`, `vcpu`, `ram_gb` and `price` are required. `code`, `disk_gb ### Latency measurement ```bash -cm -X POST http://localhost:8080/api/v1/latency/measure -H 'Content-Type: application/json' \ +cm -X POST http://localhost:8999/api/v1/latency/measure -H 'Content-Type: application/json' \ -d '{"host": "ash-speed.hetzner.com", "city": "was"}' # -> {"host": "...", "city": "Washington DC", "probe_scope": "city", "min_ms": ..., "results": [{"probe": "Washington, US (...)", "avg_ms": ...}, ...]} ``` diff --git a/TEST.md b/TEST.md index aa9e359..eb37321 100644 --- a/TEST.md +++ b/TEST.md @@ -27,7 +27,7 @@ docker compose logs | grep -i admin ## Part A: Browser -Open http://localhost:8080. +Open http://localhost:8999. ### A1. Sign-in @@ -37,7 +37,7 @@ Open http://localhost:8080. sign-in attempts; try again in … s". - [ ] **A1.4** The correct password (after the lock expires, or from another browser) opens the app. The header shows ` ▾`, **Edit Contabo prices** and **Refresh live prices**. -- [ ] **A1.5** Opening http://localhost:8080/docs while signed in shows the Swagger API docs. Signed out, +- [ ] **A1.5** Opening http://localhost:8999/docs while signed in shows the Swagger API docs. Signed out, it redirects to `/login`. ### A2. Software tiers and sizing @@ -141,14 +141,14 @@ Use a private window, or sign out first. incorrect". Then use the right one. **Expect:** "Password changed." - [ ] **A9.6** As admin, **Disable** alice. In alice's window, reload. **Expect:** back to the sign-in page, and alice can't sign in. Re-enable her afterwards. -- [ ] **A9.7** **Sign out** returns to `/login`. Opening http://localhost:8080/ again redirects to `/login`. +- [ ] **A9.7** **Sign out** returns to `/login`. Opening http://localhost:8999/ again redirects to `/login`. --- ## Part B: API (curl) ```bash -export BASE=http://localhost:8080/api/v1 +export BASE=http://localhost:8999/api/v1 export KEY=cmk_... # alice's key from A8.1 (role: user) export ADMIN_KEY=cmk_... # create one for yourself under Account → API keys code() { curl -s -o /dev/null -w "%{http_code}\n" "$@"; } @@ -161,8 +161,8 @@ code() { curl -s -o /dev/null -w "%{http_code}\n" "$@"; } - [ ] **B1.3** `code -H "Authorization: Bearer $KEY" $BASE/tiers` → **200**. - [ ] **B1.4** `code -H "X-API-Key: cmk_deadbeef_nope" $BASE/tiers` → **401**. - [ ] **B1.5** `curl -s -H "X-API-Key: $KEY" $BASE/auth/me` → `"username": "alice", "role": "user", "auth": "api_key"`. -- [ ] **B1.6** `code http://localhost:8080/healthz` → **200** without a key. -- [ ] **B1.7** `code http://localhost:8080/openapi.json` → **401**. With `-H "X-API-Key: $KEY"` → **200**. +- [ ] **B1.6** `code http://localhost:8999/healthz` → **200** without a key. +- [ ] **B1.7** `code http://localhost:8999/openapi.json` → **401**. With `-H "X-API-Key: $KEY"` → **200**. ### B2. Reference data diff --git a/docker-compose.yml b/docker-compose.yml index 0bcd051..87a0a1a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: build: . image: coremarket:latest ports: - - "8080:8080" + - "8999:8999" environment: LIVE_PRICING: "1" # 0 = use bundled catalog only LIVE_REFRESH_HOURS: "24"