@@ -138,49 +138,102 @@ Security note:
138138This is the lowest “monthly bill” option if you already have hardware, but you must handle:
139139patching, backups, and uptime.
140140
141- ### B1) Run Postgres + backend on the server
141+ ### B0) Your chosen domain + FRP ports
142142
143- Recommended :
144- - Use Docker Compose.
145- - Keep Postgres private (not exposed to the internet).
146- - Expose only the reverse proxy (80/443).
143+ You chose :
144+ - Backend domain: ` api.easyrelocate.net `
145+ - Tunnel: ` frp ` (you can forward any port)
146+ - Tokens: self-serve tokens enabled ( ` ENABLE_PUBLIC_WORKSPACE_ISSUE=1 ` )
147147
148- Minimum you need :
149- - A public backend URL (e.g. ` https://api.example.com ` )
150- - ` DATABASE_URL ` pointing at the Postgres container
148+ For Caddy automatic HTTPS, you should forward :
149+ - ** remote 80 → server 80 ** (for ACME HTTP-01 challenge )
150+ - ** remote 443 → server 443 ** (for HTTPS traffic)
151151
152- Example ` DATABASE_URL ` (Compose network):
153- ``` text
154- postgresql+psycopg://easyrelocate_user:DB_PASSWORD@postgres:5432/easyrelocate
152+ ### B1) Prepare the server (Ubuntu miniPC)
153+
154+ 1 . Install Docker + Docker Compose plugin on the server.
155+ 2 . Clone the repo:
156+ ``` bash
157+ git clone https://github.com/YuWei-CH/EasyRelocate.git
158+ cd EasyRelocate
155159```
156160
157- ### B2) Reverse proxy + HTTPS
161+ ### B2) Create server env file
158162
159- Use Caddy or Nginx to terminate HTTPS and proxy to the backend container.
163+ Create ` .env.server ` (do not commit it):
164+ ``` bash
165+ cp .env.server.example .env.server
166+ ```
160167
161- If you use FRP:
162- - Prefer mapping FRP to 443 with TLS termination at the server (Caddy/Nginx).
163- - If FRP terminates TLS upstream, ensure the backend sees correct headers and set a strict CORS allowlist.
168+ Edit ` .env.server ` :
169+ - Set ` POSTGRES_PASSWORD ` (strong password)
170+ - Set ` CORS_ALLOW_ORIGINS ` to include your Vercel domain(s)
171+ - Keep ` ENABLE_PUBLIC_WORKSPACE_ISSUE=1 ` if you want onboarding to auto-issue tokens
164172
165- ### B3) Vercel config
173+ ### B3) Start Postgres + backend + HTTPS proxy (Docker Compose)
166174
167- Set :
168- ``` text
169- VITE_API_BASE_URL=https://api.example.com
175+ On the server :
176+ ``` bash
177+ docker compose -f docker-compose.server.yml --env-file .env.server up -d --build
170178```
171179
172- And on the backend:
180+ Or use the helper script:
181+ ``` bash
182+ ENV_FILE=.env.server bash deploy/server-deploy.sh
183+ ```
184+
185+ Check:
186+ ``` bash
187+ docker compose -f docker-compose.server.yml --env-file .env.server ps
188+ ```
189+
190+ ### B4) Configure FRP
191+
192+ On your ** FRP server** (public machine), ensure ports 80/443 are open.
193+
194+ On your ** miniPC** , configure ` frpc ` to forward:
195+ - ` api.easyrelocate.net:80 ` → ` miniPC:80 `
196+ - ` api.easyrelocate.net:443 ` → ` miniPC:443 `
197+
198+ Once the DNS for ` api.easyrelocate.net ` points to your FRP server and the tunnel is active,
199+ visit:
200+ - ` https://api.easyrelocate.net/api/health `
201+
202+ You should see:
203+ ``` json
204+ {"status" :" ok" }
205+ ```
206+
207+ ### B5) Deploy frontend to Vercel
208+
209+ Set Vercel env vars:
173210``` text
174- CORS_ALLOW_ORIGINS=https://your-vercel-domain.vercel.app,https://your-custom-domain.com
211+ VITE_API_BASE_URL=https://api.easyrelocate.net
212+ VITE_GOOGLE_MAPS_API_KEY=YOUR_BROWSER_KEY
175213```
176214
177- ### B4) Backups (required)
215+ After deploy, open the web app and go through onboarding.
216+
217+ ### B6) Postgres backups (required)
178218
179219At minimum:
180220- daily ` pg_dump `
181221- keep 7–30 days of backups
182222- periodically test restore
183223
224+ ### B7) Security notes
225+
226+ - Do ** not** expose Postgres to the public internet (Compose keeps it internal by default).
227+ - Keep a strict ` CORS_ALLOW_ORIGINS ` allowlist (your Vercel domain + any custom domain).
228+ - Treat workspace tokens as passwords.
229+
230+ ### Files in this repo (Option B)
231+
232+ - ` docker-compose.server.yml ` — Postgres + backend + Caddy
233+ - ` deploy/Caddyfile ` — HTTPS reverse proxy for ` api.easyrelocate.net `
234+ - ` .env.server.example ` — server env template
235+ - ` deploy/server-deploy.sh ` — helper to start the stack
236+
184237## Troubleshooting
185238
186239### Frontend loads but API calls hang / abort
0 commit comments