create-user-hub 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -117,13 +117,16 @@ if (hubUrl && !(await hubAnswers(hubUrl))) {
117
117
 
118
118
  console.log(`\nCreating ${name} in ${dest}`);
119
119
  await cp(TEMPLATE, dest, { recursive: true });
120
- // npm drops .gitignore from packages, so the template ships it as gitignore.
120
+ // npm drops .gitignore from packages, so the template ships it as gitignore;
121
+ // .dockerignore travels the same way to be safe.
121
122
  await rename(join(dest, "gitignore"), join(dest, ".gitignore"));
123
+ await rename(join(dest, "dockerignore"), join(dest, ".dockerignore"));
122
124
 
123
125
  for (const file of [
124
126
  "package.json",
125
127
  "README.md",
126
128
  "CLAUDE.md",
129
+ "justfile",
127
130
  "src/routes/__root.tsx",
128
131
  "convex/hub.ts",
129
132
  ]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-user-hub",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Start a TanStack Start + Convex app with User Hub sign-in: bun create user-hub@latest my-app",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,4 +21,4 @@ A TanStack Start + Convex app whose sign-in comes from User Hub: people scan the
21
21
 
22
22
  ## Commands
23
23
 
24
- `bun run setup` (once), `bun run setup --prod <url>` (once deployed: registers the production URL so badge scans can reach the app; see the skill's "Production URL"), `bun run dev`, `bun run check`, `bun run typecheck`, `bun run build`.
24
+ `bun run setup` (once), `bun run setup --prod <url>` (once deployed: registers the production URL so badge scans can reach the app; see the skill's "Production URL"), `bun run dev`, `bun run check`, `bun run typecheck`, `bun run build`, `just build` / `just push` (deploy Convex to production and build the Docker image against it; `IMAGE` sets the registry path; the container needs no env).
@@ -0,0 +1,36 @@
1
+ # syntax=docker/dockerfile:1
2
+
3
+ # TanStack Start built by Vite, served by Bun (server.ts). Build it with
4
+ # `just build` or `just push`, which also deploy Convex to production.
5
+ FROM oven/bun:1.4-slim AS base
6
+ WORKDIR /app
7
+
8
+ # Dependencies, cached while package.json and the lockfile are unchanged.
9
+ FROM base AS deps
10
+ COPY --link bun.lock package.json ./
11
+ RUN bun install --frozen-lockfile
12
+
13
+ # Build: vite build emits dist/client and dist/server/server.js. Both VITE_
14
+ # values are public and inlined into the bundle, so they are build arguments.
15
+ FROM deps AS build
16
+ COPY . .
17
+ ARG VITE_CONVEX_URL
18
+ ARG VITE_HUB_URL
19
+ RUN test -n "$VITE_CONVEX_URL" -a -n "$VITE_HUB_URL" || (echo "Pass --build-arg VITE_CONVEX_URL=… and --build-arg VITE_HUB_URL=…, or run just build" && exit 1)
20
+ ENV NODE_ENV=production CI=1 VITE_CONVEX_URL=${VITE_CONVEX_URL} VITE_HUB_URL=${VITE_HUB_URL}
21
+ RUN rm -rf dist .tanstack node_modules/.vite && bunx --bun vite build && bun run typecheck
22
+
23
+ # Production dependencies only.
24
+ FROM base AS prod-deps
25
+ COPY --link bun.lock package.json ./
26
+ RUN bun install --frozen-lockfile --production
27
+
28
+ # Runtime: no environment needed. Convex holds HUB_ISSUER and HUB_JWKS.
29
+ FROM base AS runner
30
+ ENV NODE_ENV=production PORT=3000
31
+ COPY --from=prod-deps /app/node_modules ./node_modules
32
+ COPY --from=build /app/dist ./dist
33
+ COPY --link server.ts package.json ./
34
+ USER bun
35
+ EXPOSE 3000
36
+ CMD ["bun", "run", "server.ts"]
@@ -15,6 +15,15 @@ A TanStack Start + Convex app with User Hub sign-in: people scan their badge and
15
15
  3. `bun run dev`, then open http://localhost:3000. You are sent to the hub to pick who to be, then back signed in.
16
16
  4. Once the app is deployed: `bun run setup --prod https://your-app.example.com`, so badge scans can reach it. Setup asks for this the first time; press Enter to skip until you deploy.
17
17
 
18
+ ## Deploy
19
+
20
+ The app ships as a Docker image served by Bun (`Dockerfile`, `server.ts`); it needs no environment variables at runtime. With [just](https://just.systems) and Docker:
21
+
22
+ - `just build`: deploys the Convex functions to production, then builds the image against that deployment and loads it into Docker. Try it with `docker run -p 3000:3000 __APP_KEY__`.
23
+ - `just push`: the same, built for servers (amd64) and pushed. Set your registry path first: `IMAGE=registry.example.com/team/__APP_KEY__ just push`, or edit `image` at the top of the `justfile`.
24
+
25
+ Then serve the container (port 3000) at your production URL, make sure the hub knows that URL (`bun run setup --prod <url>`), and schedule the app in the hub or force it live.
26
+
18
27
  ## What's inside
19
28
 
20
29
  - `src/routes/__root.tsx`: the hub providers inside `<body>`; `HubSignedIn` shows pages only to signed-in people.
@@ -24,6 +33,6 @@ A TanStack Start + Convex app with User Hub sign-in: people scan their badge and
24
33
 
25
34
  ## Commands
26
35
 
27
- `bun run dev`, `bun run check` (Biome), `bun run typecheck`, `bun run build`, `bun run start` (production server).
36
+ `bun run dev`, `bun run check` (Biome), `bun run typecheck`, `bun run build`, `bun run start` (production server), `just build`, `just push`.
28
37
 
29
38
  Coding agents: see `CLAUDE.md` and the `user-hub-auth` skill in `.claude/skills`.
@@ -0,0 +1,32 @@
1
+ # Rebuilt inside the image
2
+ node_modules
3
+ dist
4
+ .output
5
+ .tanstack
6
+ .nitro
7
+ .vinxi
8
+
9
+ # Local env and secrets: the public build values come in as build arguments
10
+ .env
11
+ .env.*
12
+ !.env.example
13
+
14
+ # VCS, editors, OS. .gitignore stays: Tailwind v4 reads it to decide what to
15
+ # scan, so without it the image's CSS differs from a local build.
16
+ .git
17
+ .DS_Store
18
+ .idea
19
+ .vscode
20
+
21
+ # Agent files
22
+ .agents
23
+ .claude
24
+
25
+ # Not needed to build or run
26
+ scripts
27
+ justfile
28
+ README.md
29
+ AGENTS.md
30
+ CLAUDE.md
31
+ Dockerfile
32
+ .dockerignore
@@ -0,0 +1,19 @@
1
+ # Production image. Both recipes deploy the Convex functions to production
2
+ # first and build the image against that deployment: `convex deploy --cmd`
3
+ # hands the build the production VITE_CONVEX_URL, and VITE_HUB_URL comes from
4
+ # .env.local (written by bun run setup).
5
+
6
+ set dotenv-load
7
+ set dotenv-filename := ".env.local"
8
+
9
+ # Your registry path, e.g. registry.example.com/team/__APP_KEY__ (or IMAGE=…).
10
+ image := env("IMAGE", "__APP_KEY__")
11
+ tag := env("TAG", "latest")
12
+
13
+ # Deploy Convex, then build the image for this machine and load it into Docker
14
+ build:
15
+ bunx convex deploy --cmd 'docker build --build-arg VITE_CONVEX_URL="$VITE_CONVEX_URL" --build-arg VITE_HUB_URL="$VITE_HUB_URL" -t {{image}}:{{tag}} --load .'
16
+
17
+ # Deploy Convex, then build the image for servers (amd64) and push it
18
+ push:
19
+ bunx convex deploy --cmd 'docker build --platform linux/amd64 --build-arg VITE_CONVEX_URL="$VITE_CONVEX_URL" --build-arg VITE_HUB_URL="$VITE_HUB_URL" -t {{image}}:{{tag}} --push .'
@@ -16,7 +16,7 @@
16
16
  "@tailwindcss/vite": "^4.3.3",
17
17
  "@tanstack/react-router": "^1.170.41",
18
18
  "@tanstack/react-start": "^1.168.60",
19
- "@user-hub/auth": "^0.1.4",
19
+ "@user-hub/auth": "^0.2.0",
20
20
  "class-variance-authority": "^0.7.1",
21
21
  "cn": "^0.4.0",
22
22
  "convex": "^1.46.0",