swapping ports

This commit is contained in:
C-West8
2026-10-23 10:09:47 -05:00
parent 5d105bd0ed
commit 064246ce42
5 changed files with 15 additions and 11 deletions

View File

@@ -19,7 +19,7 @@ RUN npm run build && npm prune --omit=dev
# Runtime stage: the built server, production dependencies and the migrations. # Runtime stage: the built server, production dependencies and the migrations.
FROM base FROM base
ENV NODE_ENV=production \ ENV NODE_ENV=production \
PORT=3000 \ PORT=3288 \
DATABASE_PATH=/data/sync.db DATABASE_PATH=/data/sync.db
COPY --from=build /app/package.json ./ COPY --from=build /app/package.json ./
COPY --from=build /app/node_modules ./node_modules COPY --from=build /app/node_modules ./node_modules
@@ -28,7 +28,7 @@ COPY --from=build /app/drizzle ./drizzle
RUN mkdir /data && chown node:node /data RUN mkdir /data && chown node:node /data
USER node USER node
VOLUME /data VOLUME /data
EXPOSE 3000 EXPOSE 3288
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \ HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD ["node", "-e", "fetch(`http://127.0.0.1:${process.env.PORT}/healthz`).then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1))"] CMD ["node", "-e", "fetch(`http://127.0.0.1:${process.env.PORT}/healthz`).then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]
CMD ["node", "build"] CMD ["node", "build"]

View File

@@ -25,7 +25,7 @@ In development. The sync engine, database, scheduler and web UI are built, and y
```sh ```sh
npm install npm install
cp .env.example .env # simulated mode, admin login admin / change-me cp .env.example .env # simulated mode, admin login admin / change-me
npm run dev npm run dev # http://localhost:5288
``` ```
In simulated mode, SharePoint and ACC are in-memory stand-ins. A demo project is created at startup, filled with sample files, and edited at random every 45 seconds so there's something to watch. One file (`Corrupt model.rvt`) is always rejected, so the issues list has something in it. Nothing persists: a restart starts over. In simulated mode, SharePoint and ACC are in-memory stand-ins. A demo project is created at startup, filled with sample files, and edited at random every 45 seconds so there's something to watch. One file (`Corrupt model.rvt`) is always rejected, so the issues list has something in it. Nothing persists: a restart starts over.
@@ -38,7 +38,7 @@ In simulated mode, SharePoint and ACC are in-memory stand-ins. A demo project is
| `npm run build` | Production build into `build/` (`node build` runs it; run it from the repo root so `drizzle/` migrations are found) | | `npm run build` | Production build into `build/` (`node build` runs it; run it from the repo root so `drizzle/` migrations are found) |
| `npm run image:publish` | Checks, builds and pushes the Docker image to the Gitea registry (see the runbook) | | `npm run image:publish` | Checks, builds and pushes the Docker image to the Gitea registry (see the runbook) |
To try the Docker image locally: put `ADMIN_USERNAME`, `ADMIN_PASSWORD`, `SESSION_SECRET`, `SYNC_BACKEND=simulated` and `ORIGIN=http://localhost:3000` in `.env`, then run `docker compose up -d --build`. To try the Docker image locally: put `ADMIN_USERNAME`, `ADMIN_PASSWORD`, `SESSION_SECRET`, `SYNC_BACKEND=simulated` and `ORIGIN=http://localhost:3288` in `.env`, then run `docker compose up -d --build` and open http://localhost:3288.
## Stack ## Stack

View File

@@ -7,7 +7,7 @@ services:
context: . context: .
args: args:
# Local builds only: set when serving plain HTTP, to the exact address users open, # Local builds only: set when serving plain HTTP, to the exact address users open,
# e.g. http://sync-server:3000 # e.g. http://sync-server:3288
ORIGIN: ${ORIGIN:-} ORIGIN: ${ORIGIN:-}
# Set IMAGE to a commit tag (e.g. ...:1a2b3c4) to roll back # Set IMAGE to a commit tag (e.g. ...:1a2b3c4) to roll back
image: ${IMAGE:-primegit.primecontrols-dev.com/c.west/sharepoint-acc-sync:latest} image: ${IMAGE:-primegit.primecontrols-dev.com/c.west/sharepoint-acc-sync:latest}
@@ -15,7 +15,7 @@ services:
pull_policy: always pull_policy: always
restart: unless-stopped restart: unless-stopped
ports: ports:
- '${HOST_PORT:-3000}:3000' - '${HOST_PORT:-3288}:3288'
environment: environment:
SYNC_BACKEND: ${SYNC_BACKEND:-live} SYNC_BACKEND: ${SYNC_BACKEND:-live}
ADMIN_USERNAME: ${ADMIN_USERNAME:?Set ADMIN_USERNAME} ADMIN_USERNAME: ${ADMIN_USERNAME:?Set ADMIN_USERNAME}

View File

@@ -6,7 +6,7 @@ How to deploy, update, back up and troubleshoot the sync server.
- **One container**, from the image published to the Gitea registry (see [Publishing an image](#publishing-an-image)). Never run more than one copy: the locks that stop two syncs of the same project overlapping live inside the process. - **One container**, from the image published to the Gitea registry (see [Publishing an image](#publishing-an-image)). Never run more than one copy: the locks that stop two syncs of the same project overlapping live inside the process.
- **One volume**, `sync-data`, mounted at `/data`. It holds `sync.db`, the SQLite database with the projects, the record of which ACC item belongs to which SharePoint item, and the last 7 days of history. - **One volume**, `sync-data`, mounted at `/data`. It holds `sync.db`, the SQLite database with the projects, the record of which ACC item belongs to which SharePoint item, and the last 7 days of history.
- **Port 3000** inside the container. `HOST_PORT` sets the port on the server (default 3000). - **Port 3288** inside the container. `HOST_PORT` sets the port on the server (default 3288).
- **Health check:** `GET /healthz` answers `{"status":"ok"}` once the server has started. Docker checks it every 30 seconds, and Portainer shows the result as healthy or unhealthy. - **Health check:** `GET /healthz` answers `{"status":"ok"}` once the server has started. Docker checks it every 30 seconds, and Portainer shows the result as healthy or unhealthy.
- **Logs:** one JSON object per line on stdout. View them in Portainer under the container's logs. - **Logs:** one JSON object per line on stdout. View them in Portainer under the container's logs.
@@ -15,7 +15,7 @@ How to deploy, update, back up and troubleshoot the sync server.
Decide this before the first deploy, because it changes how the image is built. Decide this before the first deploy, because it changes how the image is built.
- **Behind an HTTPS reverse proxy** (recommended). The proxy must pass the original `Host` header on, which most do by default. Leave `ORIGIN` empty. - **Behind an HTTPS reverse proxy** (recommended). The proxy must pass the original `Host` header on, which most do by default. Leave `ORIGIN` empty.
- **Plain HTTP** on the VPN, for example `http://sync-server:3000`. Set `ORIGIN` to exactly the address people will type, with no trailing slash. `ORIGIN` is fixed when the image is built, so the app only works at that one address: not by IP if `ORIGIN` uses a name, and not on a different port. So `ORIGIN` is set when [publishing an image](#publishing-an-image), not in Portainer. - **Plain HTTP** on the VPN, for example `http://sync-server:3288`. Set `ORIGIN` to exactly the address people will type, with no trailing slash. `ORIGIN` is fixed when the image is built, so the app only works at that one address: not by IP if `ORIGIN` uses a name, and not on a different port. So `ORIGIN` is set when [publishing an image](#publishing-an-image), not in Portainer.
If `ORIGIN` is wrong or missing over plain HTTP, pages still load, but every button that submits something fails with "Cross-site POST form submissions are forbidden". If `ORIGIN` is wrong or missing over plain HTTP, pages still load, but every button that submits something fails with "Cross-site POST form submissions are forbidden".
@@ -28,7 +28,7 @@ Set these in the Portainer stack's **Environment variables**, or in a `.env` fil
| `ADMIN_USERNAME` | yes | | Login for the admin pages | | `ADMIN_USERNAME` | yes | | Login for the admin pages |
| `ADMIN_PASSWORD` | yes | | Password for the admin pages | | `ADMIN_PASSWORD` | yes | | Password for the admin pages |
| `SESSION_SECRET` | yes | | Signs admin logins. Any long random string, e.g. the output of `node -e "console.log(crypto.randomBytes(32).toString('hex'))"`. Changing it logs admins out | | `SESSION_SECRET` | yes | | Signs admin logins. Any long random string, e.g. the output of `node -e "console.log(crypto.randomBytes(32).toString('hex'))"`. Changing it logs admins out |
| `HOST_PORT` | no | `3000` | Port on the server | | `HOST_PORT` | no | `3288` | Port on the server |
| `IMAGE` | no | latest published | Image to run. Set it to a commit tag to roll back (see [Rolling back](#rolling-back)) | | `IMAGE` | no | latest published | Image to run. Set it to a commit tag to roll back (see [Rolling back](#rolling-back)) |
| `SYNC_BACKEND` | no | `live` | `simulated` runs the in-memory demo instead (nothing is saved) | | `SYNC_BACKEND` | no | `live` | `simulated` runs the in-memory demo instead (nothing is saved) |
| `TZ` | no | `America/Chicago` | Time zone the status pages show times in | | `TZ` | no | `America/Chicago` | Time zone the status pages show times in |
@@ -62,7 +62,7 @@ It stops at the first failure. In order, it:
3. builds the image from the `Dockerfile`, pulling the newest Node base image; 3. builds the image from the `Dockerfile`, pulling the newest Node base image;
4. pushes it tagged with the commit's short hash (for example `1a2b3c4`), then as `latest`. 4. pushes it tagged with the commit's short hash (for example `1a2b3c4`), then as `latest`.
Over plain HTTP, set `ORIGIN` in the same shell first, for example in PowerShell `$env:ORIGIN = 'http://sync-server:3000'`, or in bash `ORIGIN=http://sync-server:3000 npm run image:publish`. The script prints the `ORIGIN` it's using before it starts. It ignores `.env`, so a local `ORIGIN=http://localhost:3000` never ends up in a published image. Over plain HTTP, set `ORIGIN` in the same shell first, for example in PowerShell `$env:ORIGIN = 'http://sync-server:3288'`, or in bash `ORIGIN=http://sync-server:3288 npm run image:publish`. The script prints the `ORIGIN` it's using before it starts. It ignores `.env`, so a local `ORIGIN=http://localhost:3288` never ends up in a published image.
## First deploy (Portainer) ## First deploy (Portainer)

View File

@@ -13,12 +13,16 @@ export default defineConfig({
adapter: adapter(), adapter: adapter(),
paths: { paths: {
// Kit 3 fixes the site's address at build time. When unset, requests are assumed to // Kit 3 fixes the site's address at build time. When unset, requests are assumed to
// arrive over HTTPS (e.g. through a reverse proxy). Set ORIGIN (e.g. http://sync:3000) // arrive over HTTPS (e.g. through a reverse proxy). Set ORIGIN (e.g. http://sync:3288)
// when serving plain HTTP, or form posts are rejected as cross-site. // when serving plain HTTP, or form posts are rejected as cross-site.
origin: process.env.ORIGIN || undefined origin: process.env.ORIGIN || undefined
} }
}) })
], ],
// Off the defaults (5173/4173), which other projects on the same machines use. strictPort
// fails loudly instead of quietly moving to the next free port.
server: { port: 5288, strictPort: true },
preview: { port: 4288, strictPort: true },
test: { test: {
expect: { requireAssertions: true }, expect: { requireAssertions: true },
projects: [ projects: [