feat: add Dockerfile for self-hosted deployment#36
feat: add Dockerfile for self-hosted deployment#36felipeelias wants to merge 2 commits intoEveryInc:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an official Dockerfile to enable self-hosted container deployments of the Proof SDK server (including building the Vite frontend and native deps) with a multi-stage build.
Changes:
- Introduces a multi-stage Docker build (builder compiles deps/builds frontend; runtime is slim + non-root + dumb-init).
- Copies built frontend artifacts into the runtime image and runs the server via
tsx(matchingnpm run serve).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Build frontend SPA (Vite → dist/), then merge into public/ so the | ||
| # Express static middleware can serve the built assets alongside existing | ||
| # static files, then prune dev dependencies. | ||
| # Single RUN so dev deps don't persist in any layer. | ||
| RUN npm run build \ | ||
| && cp -r dist/* public/ \ |
There was a problem hiding this comment.
cp -r dist/* public/ will copy dist/index.html into public/, and because express.static(.../public) is registered before app.get('/') (see server/index.ts), requests to / will start serving the SPA index.html instead of the server’s landing page route. To avoid this behavior change, only copy the built asset directory into public (e.g. dist/assets -> public/assets) while keeping dist/index.html in dist/ for share-web-routes to read.
| # Build frontend SPA (Vite → dist/), then merge into public/ so the | |
| # Express static middleware can serve the built assets alongside existing | |
| # static files, then prune dev dependencies. | |
| # Single RUN so dev deps don't persist in any layer. | |
| RUN npm run build \ | |
| && cp -r dist/* public/ \ | |
| # Build frontend SPA (Vite → dist/), then copy only built assets into | |
| # public/ so Express can serve them, while keeping dist/index.html in dist/ | |
| # for the server routes to read, then prune dev dependencies. | |
| # Single RUN so dev deps don't persist in any layer. | |
| RUN npm run build \ | |
| && mkdir -p public/assets \ | |
| && cp -r dist/assets/* public/assets/ \ |
There was a problem hiding this comment.
The copy is intentional. Serving the SPA at / via public/index.html is the expected behavior. share-web-routes reads dist/index.html separately for document pages (/d/... routes), not the root. Both paths work correctly with this setup.
Hey, thanks for releasing Proof. I started using it, hosting it myself, and this is the Dockerfile I'm using. Thought it would be great to share.
Summary
Add a multi-stage Dockerfile so anyone can self-host the Proof SDK server with
docker build && docker run.Why
No official way to run Proof SDK in a container. This makes self-hosting straightforward: build the image, run it, configure with environment variables.
What
better-sqlite3) and builds the Vite frontend, production stage is a cleannode:22-slimtsxfor server execution (same asnpm run serve) sincesrc/files don't compile cleanly undertsconfig.server.jsondist/*intopublic/so the Express static middleware serves built assets (the server reads from both directories)nodeuser withdumb-initfor proper signal handlingEnvironment variables
DATABASE_PATHproof-share.dbPORT4000PROOF_PUBLIC_BASE_URLPROOF_COLLAB_SIGNING_SECRETPROOF_CORS_ALLOW_ORIGINSSNAPSHOT_DIRsnapshots/Usage
Compose example
Known limitation
The repo gitignores
package-lock.json, so the build usesnpm installinstead ofnpm ci. Dependency versions may drift between builds.