Skip to content

chore(docker): deploy with compose instead of pm2 - #1048

Open
ugcodrr wants to merge 29 commits into
mainfrom
chore/docker-deploy
Open

ugcodrr wants to merge 29 commits into
mainfrom
chore/docker-deploy

Conversation

@ugcodrr

@ugcodrr ugcodrr commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Description: Deploys delete and rebuild dist in the checkout pm2 runs the apps from, so a failed build leaves pm2 nothing to restart. Now a tag builds an image for each app on the server and runs them with compose.prod.yml.

  1. There's no registry. The images are built on the server and stay there. Each deploy prunes ones older than two weeks, except the deploy it replaces.
  2. Each app gets SENTRY_RELEASE set to the deployed commit, so Sentry ties errors to a deploy.
  3. The leaderboard limiter reads the Redis URL from config.js like the other apps. It used REDIS_URL, which nothing sets. The api-key script now waits for that URL too, instead of handing ioredis a promise.
  4. Apps no longer restart daily at 20:00 UTC like they did under pm2.
  5. The README now has the compose commands for the server, the blur-backgrounds step a fresh checkout was missing, and pnpm --filter instead of pnpm workspace, which isn't a command.
  6. A deploy fails when the API doesn't start answering requests, so a broken API shows up in Actions.

Testing: all five images build for linux/amd64 and start. Against a local Mongo and Redis, the API passes its healthcheck and the limiter runs a full pass, and the API image renders a skin on lavapipe. Compose hasn't built them on the server yet, so step 2 below is the first real run.

Todo, in order:

  1. Merge without a tag.
  2. On the server, in a clone of main with the private assets, run echo "TAG=$(git rev-parse HEAD)" > .env and docker compose -f compose.prod.yml build. pm2 keeps serving while it builds.
  3. Switch over in the same folder: pm2 delete all && pm2 save --force && pm2 unstartup && docker compose -f compose.prod.yml up -d --wait. Check pm2 ls first: if anything besides the five apps runs under pm2, replace the pm2 part with pm2 delete <deploy checkout>/pm2.config.cjs && pm2 save --force, so the rest keeps running and starting on boot. To go back, docker compose -f compose.prod.yml down, then pm2 start pm2.config.cjs && pm2 save && pm2 startup from the current deploy checkout.
  4. Tag as usual. A v* tag before step 3 would start a second copy of every app next to pm2.

After that, run compose commands from the deploy checkout, where .env holds the deployed commit. To roll back, TAG=<older sha> docker compose -f compose.prod.yml up -d --no-build. Without --no-build, compose rebuilds the current code under the old tag.

Conflicts with #1183, which renames the scripts to .ts. Whichever lands second has to change the limiter's command in compose.prod.yml to node src/limit-redis.ts, since git won't flag it.

Supersedes #1047
Closes #1030
Closes #883

@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
statsify Ignored Ignored Nov 9, 2026 3:25am UTC

--pull always restarted Redis whenever its tag was rebuilt upstream; app tags are new each deploy so compose pulls them anyway. Setting json-file keeps the log rotation options valid if the daemon defaults to another driver.
Node 24.7.0's corepack (0.34) looks for bin/pnpm.cjs, which pnpm 11+ no longer ships, so every stage failed. Also drops turbo's caches from the image, and builds for amd64 in the README since wasm-pack's arm64 wasm-bindgen needs a newer glibc than bookworm's.
@ugcodrr
ugcodrr force-pushed the chore/docker-deploy branch from 4d8464a to 918cf9f Compare November 2, 2026 02:42
@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

Deployment failed for project statsify with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/statsify-net?upgradeToPro=build-rate-limit

@ugcodrr
ugcodrr marked this pull request as ready for review November 2, 2026 02:42
@ugcodrr
ugcodrr removed this pull request from stack #1061 November 9, 2026 01:37
@ugcodrr
ugcodrr changed the base branch from chore/docker-image to main November 9, 2026 01:37

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant