Support www redirects in Docker install

This commit is contained in:
cyph3rasi
2026-03-07 20:11:40 -08:00
parent 17baf8e4f0
commit 588307d21e
4 changed files with 15 additions and 32 deletions
+6 -32
View File
@@ -1,11 +1,8 @@
# How To Work On Synapsis # How To Work On Synapsis
This is the practical workflow for developing Synapsis without turning every bugfix into a full Docker release. This is the practical workflow for developing Synapsis without turning every bugfix into a full Docker release.
## The Basic Rule ## Basic Rule
Use three different loops for three different jobs: Use three different loops for three different jobs:
1. `npm run dev` for normal feature work and bugfixes 1. `npm run dev` for normal feature work and bugfixes
2. local Docker source builds when you need container parity 2. local Docker source builds when you need container parity
3. GHCR publish only when you actually want the server to update 3. GHCR publish only when you actually want the server to update
@@ -13,7 +10,6 @@ Use three different loops for three different jobs:
Do **not** rebuild and push a Docker image for every tiny fix. Batch fixes together, verify them locally, then publish when the server needs the new version. Do **not** rebuild and push a Docker image for every tiny fix. Batch fixes together, verify them locally, then publish when the server needs the new version.
## 1. Normal Local Development ## 1. Normal Local Development
Use this for most day-to-day work. Use this for most day-to-day work.
```bash ```bash
@@ -38,10 +34,7 @@ Use this loop when:
- you do not specifically need to test the Docker runtime - you do not specifically need to test the Docker runtime
## 2. Local Docker Parity Test ## 2. Local Docker Parity Test
Use this when you want to know whether the app still works inside the actual container setup. This compose file builds from your local source tree:
Use this when you want to know whether the app still works inside the actual container setup.
This compose file builds from your local source tree:
```bash ```bash
cd docker cd docker
@@ -49,9 +42,7 @@ cp .env.example .env
docker compose up --build docker compose up --build
``` ```
That uses: That uses [docker/docker-compose.yml](/Users/christopher/Dev/Synapsis/Synapsis/docker/docker-compose.yml) and [docker/Dockerfile](/Users/christopher/Dev/Synapsis/Synapsis/docker/Dockerfile).
- [docker/docker-compose.yml](/Users/christopher/Dev/Synapsis/Synapsis/docker/docker-compose.yml)
- [docker/Dockerfile](/Users/christopher/Dev/Synapsis/Synapsis/docker/Dockerfile)
Use this loop when: Use this loop when:
- Docker-specific startup behavior matters - Docker-specific startup behavior matters
@@ -59,22 +50,15 @@ Use this loop when:
- you changed env handling, healthchecks, migrations, ports, or install flow - you changed env handling, healthchecks, migrations, ports, or install flow
## 3. Production Image Publish ## 3. Production Image Publish
Use this only when you want the server or end users to pull a new image. The production install uses [docker-compose.yml](/Users/christopher/Dev/Synapsis/Synapsis/docker-compose.yml) and `ghcr.io/gnosyslabs/synapsis:latest`.
Use this only when you want the server or end users to pull a new image.
The production install uses:
- [docker-compose.yml](/Users/christopher/Dev/Synapsis/Synapsis/docker-compose.yml)
- image: `ghcr.io/gnosyslabs/synapsis:latest`
### First-time GHCR auth on this machine ### First-time GHCR auth on this machine
```bash ```bash
gh auth refresh -h github.com -s read:packages -s write:packages gh auth refresh -h github.com -s read:packages -s write:packages
gh auth token | docker login ghcr.io -u YOUR_GITHUB_USERNAME --password-stdin gh auth token | docker login ghcr.io -u YOUR_GITHUB_USERNAME --password-stdin
``` ```
### Publish the image ### Publish the image
Push code first: Push code first:
```bash ```bash
@@ -101,7 +85,6 @@ That publishes:
If you are not on a Mac/Colima setup, swap `--builder colima` for whatever local buildx builder you use. If you are not on a Mac/Colima setup, swap `--builder colima` for whatever local buildx builder you use.
## 4. Update The Server ## 4. Update The Server
Once a new image is published, update the server with: Once a new image is published, update the server with:
```bash ```bash
@@ -119,13 +102,10 @@ docker compose images
``` ```
## 5. Which Compose File Is Which ## 5. Which Compose File Is Which
There are two main Docker compose paths in this repo. There are two main Docker compose paths in this repo.
### Local source-build compose ### Local source-build compose
File: [docker/docker-compose.yml](/Users/christopher/Dev/Synapsis/Synapsis/docker/docker-compose.yml)
File:
- [docker/docker-compose.yml](/Users/christopher/Dev/Synapsis/Synapsis/docker/docker-compose.yml)
Purpose: Purpose:
- local Docker testing - local Docker testing
@@ -133,9 +113,7 @@ Purpose:
- no GHCR push required - no GHCR push required
### Production install compose ### Production install compose
File: [docker-compose.yml](/Users/christopher/Dev/Synapsis/Synapsis/docker-compose.yml)
File:
- [docker-compose.yml](/Users/christopher/Dev/Synapsis/Synapsis/docker-compose.yml)
Purpose: Purpose:
- end-user install - end-user install
@@ -145,9 +123,7 @@ Purpose:
Do not confuse them. Do not confuse them.
## 6. Recommended Workflow ## 6. Recommended Workflow
This is the default path that makes the most sense for Synapsis: This is the default path that makes the most sense for Synapsis:
1. Make code changes locally 1. Make code changes locally
2. Run `npm run type-check` 2. Run `npm run type-check`
3. Run `npm run build` 3. Run `npm run build`
@@ -158,7 +134,6 @@ This is the default path that makes the most sense for Synapsis:
8. Pull and restart on the server 8. Pull and restart on the server
## 7. When To Publish A New Docker Image ## 7. When To Publish A New Docker Image
Publish when: Publish when:
- you want the fix on the real server - you want the fix on the real server
- you changed install/runtime/container behavior - you changed install/runtime/container behavior
@@ -169,7 +144,6 @@ Do not publish just because:
- one small API bug was fixed and not needed on the server yet - one small API bug was fixed and not needed on the server yet
## 8. Current Install Reality ## 8. Current Install Reality
For clean servers, the normal install path is: For clean servers, the normal install path is:
```bash ```bash
+2
View File
@@ -25,6 +25,8 @@ docker compose up -d
Done! Your node is live at `https://your-domain.com` with automatic SSL. No build step. No dependencies. No fuss. Done! Your node is live at `https://your-domain.com` with automatic SSL. No build step. No dependencies. No fuss.
Database migrations run automatically on startup and during updates. Database migrations run automatically on startup and during updates.
Set `DOMAIN` to the canonical host you want Synapsis to live on. If you also create a `www` DNS record, the bundled Caddy setup will redirect `www` to that canonical domain automatically.
If your server already has nginx or another reverse proxy using `80/443`, use the advanced mode instead: If your server already has nginx or another reverse proxy using `80/443`, use the advanced mode instead:
```bash ```bash
+4
View File
@@ -1,6 +1,10 @@
# Caddyfile for Synapsis # Caddyfile for Synapsis
# Automatic HTTPS via Let's Encrypt # Automatic HTTPS via Let's Encrypt
www.{$DOMAIN} {
redir https://{$DOMAIN}{uri} permanent
}
{$DOMAIN} { {$DOMAIN} {
# Reverse proxy to Synapsis app (port is set via APP_PORT env var) # Reverse proxy to Synapsis app (port is set via APP_PORT env var)
reverse_proxy app:{$APP_PORT:3000} reverse_proxy app:{$APP_PORT:3000}
+3
View File
@@ -41,6 +41,9 @@ Edit `.env` and set these required values (domain should be host only, no scheme
| `AUTH_SECRET` | Run: `openssl rand -hex 32` | | `AUTH_SECRET` | Run: `openssl rand -hex 32` |
| `ADMIN_EMAILS` | Your email address | | `ADMIN_EMAILS` | Your email address |
Use the bare/canonical host in `DOMAIN`. Example: set `DOMAIN=synapsis.example.com`, not `www.synapsis.example.com`.
If you also want `www.synapsis.example.com` to work, create a DNS record for `www` pointing to the same server. The bundled Caddy config will redirect `www` to the canonical `DOMAIN`.
Optional (advanced): Optional (advanced):
- `NEXT_PUBLIC_NODE_DOMAIN` to override the node domain (defaults to `DOMAIN`) - `NEXT_PUBLIC_NODE_DOMAIN` to override the node domain (defaults to `DOMAIN`)
- `NEXT_PUBLIC_APP_URL` to override the public app URL used by background jobs (auto-derived from the node domain) - `NEXT_PUBLIC_APP_URL` to override the public app URL used by background jobs (auto-derived from the node domain)