Skip to content

Commit 2a79053

Browse files
fix(cli): use full node image for Vite+ Docker builds
Use the full Node 24 image for Vite+ Docker web builds so vp build has access to the system CA bundle. Keep non-Vite+ Docker web builds on node:24-slim.
1 parent 1e899fe commit 2a79053

7 files changed

Lines changed: 47 additions & 10 deletions

File tree

apps/cli/test/deployment.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,8 @@ describe("Deployment Configurations", () => {
713713
expect(compose).toContain("VITE_SERVER_URL: http://localhost:3000");
714714
expect(webDockerfile).toContain("ARG VITE_SERVER_URL");
715715
expect(files.get(".dockerignore")).toContain("**/.env");
716+
expect(webDockerfile).toContain("FROM node:24-slim AS builder");
717+
expect(serverDockerfile).toContain("FROM node:24-slim AS base");
716718

717719
// SPA frontend builds static assets served by nginx with an SPA fallback
718720
expect(webDockerfile).toContain("FROM nginx:alpine");
@@ -843,10 +845,45 @@ describe("Deployment Configurations", () => {
843845
expect(viteConfig).toContain("nitro(),");
844846
expect(webPkg.dependencies.nitro).toBeDefined();
845847
// SSR chunks require() externals at runtime, so the app runs from the workspace
848+
expect(webDockerfile).toContain("FROM node:24-slim AS base");
846849
expect(webDockerfile).toContain("WORKDIR /app/apps/web");
847850
expect(webDockerfile).toContain('CMD ["node", ".output/server/index.mjs"]');
848851
});
849852

853+
it("should use the full Node 24 image for Vite+ Docker web builds", async () => {
854+
const result = await createVirtual({
855+
projectName: "docker-vite-plus",
856+
webDeploy: "docker",
857+
serverDeploy: "docker",
858+
backend: "hono",
859+
runtime: "bun",
860+
database: "postgres",
861+
orm: "prisma",
862+
auth: "better-auth",
863+
payments: "none",
864+
api: "orpc",
865+
frontend: ["tanstack-start"],
866+
addons: ["vite-plus"],
867+
examples: ["none"],
868+
dbSetup: "docker",
869+
install: false,
870+
git: false,
871+
packageManager: "bun",
872+
});
873+
874+
if (result.isErr()) {
875+
throw result.error;
876+
}
877+
878+
const files = collectFiles(result.value.root, result.value.root.path);
879+
const webDockerfile = files.get("apps/web/Dockerfile");
880+
const webPkg = JSON.parse(files.get("apps/web/package.json") ?? "{}");
881+
882+
expect(webPkg.scripts.build).toBe("vp build");
883+
expect(webDockerfile).toContain("FROM node:24 AS base");
884+
expect(webDockerfile).not.toContain("ca-certificates");
885+
});
886+
850887
it("should serve React Router SPA builds with nginx", async () => {
851888
const result = await createVirtual({
852889
projectName: "docker-react-router",

packages/template-generator/src/templates.generated.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16234,7 +16234,7 @@ EXPOSE 3001
1623416234

1623516235
CMD ["node", "apps/web/server.js"]
1623616236
`],
16237-
["deploy/docker/web/react/react-router/Dockerfile.hbs", `FROM node:24-slim AS builder
16237+
["deploy/docker/web/react/react-router/Dockerfile.hbs", `FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS builder
1623816238
{{#if (eq packageManager "bun")}}
1623916239
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
1624016240
{{/if}}
@@ -16301,7 +16301,7 @@ CMD ["nginx", "-g", "daemon off;"]
1630116301
}
1630216302
}
1630316303
`],
16304-
["deploy/docker/web/react/tanstack-router/Dockerfile.hbs", `FROM node:24-slim AS builder
16304+
["deploy/docker/web/react/tanstack-router/Dockerfile.hbs", `FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS builder
1630516305
{{#if (eq packageManager "bun")}}
1630616306
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
1630716307
{{/if}}
@@ -16368,7 +16368,7 @@ CMD ["nginx", "-g", "daemon off;"]
1636816368
}
1636916369
}
1637016370
`],
16371-
["deploy/docker/web/react/tanstack-start/Dockerfile.hbs", `FROM node:24-slim AS base
16371+
["deploy/docker/web/react/tanstack-start/Dockerfile.hbs", `FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS base
1637216372
{{#if (eq packageManager "bun")}}
1637316373
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
1637416374
{{/if}}
@@ -16425,7 +16425,7 @@ EXPOSE 3001
1642516425
WORKDIR /app/apps/web
1642616426
CMD ["node", ".output/server/index.mjs"]
1642716427
`],
16428-
["deploy/docker/web/solid/Dockerfile.hbs", `FROM node:24-slim AS builder
16428+
["deploy/docker/web/solid/Dockerfile.hbs", `FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS builder
1642916429
{{#if (eq packageManager "bun")}}
1643016430
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
1643116431
{{/if}}
@@ -16488,7 +16488,7 @@ CMD ["nginx", "-g", "daemon off;"]
1648816488
}
1648916489
}
1649016490
`],
16491-
["deploy/docker/web/svelte/Dockerfile.hbs", `FROM node:24-slim AS base
16491+
["deploy/docker/web/svelte/Dockerfile.hbs", `FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS base
1649216492
{{#if (eq packageManager "bun")}}
1649316493
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
1649416494
{{/if}}

packages/template-generator/templates/deploy/docker/web/react/react-router/Dockerfile.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:24-slim AS builder
1+
FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS builder
22
{{#if (eq packageManager "bun")}}
33
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
44
{{/if}}

packages/template-generator/templates/deploy/docker/web/react/tanstack-router/Dockerfile.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:24-slim AS builder
1+
FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS builder
22
{{#if (eq packageManager "bun")}}
33
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
44
{{/if}}

packages/template-generator/templates/deploy/docker/web/react/tanstack-start/Dockerfile.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:24-slim AS base
1+
FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS base
22
{{#if (eq packageManager "bun")}}
33
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
44
{{/if}}

packages/template-generator/templates/deploy/docker/web/solid/Dockerfile.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:24-slim AS builder
1+
FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS builder
22
{{#if (eq packageManager "bun")}}
33
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
44
{{/if}}

packages/template-generator/templates/deploy/docker/web/svelte/Dockerfile.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:24-slim AS base
1+
FROM node:24{{#unless (includes addons "vite-plus")}}-slim{{/unless}} AS base
22
{{#if (eq packageManager "bun")}}
33
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
44
{{/if}}

0 commit comments

Comments
 (0)