From 9c4e91b861b24fc1ef8b73f2f8dc654b32abc9ea Mon Sep 17 00:00:00 2001 From: Brandon Corbett Date: Fri, 20 Nov 2026 23:07:35 -0500 Subject: [PATCH] fix(docker): build the api and full-stack web services from the dev stage --- .changeset/compose-dev-target.md | 5 +++++ src/generators/docker/docker.test.ts | 11 ++++++++++- src/generators/docker/docker.ts | 11 +++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .changeset/compose-dev-target.md diff --git a/.changeset/compose-dev-target.md b/.changeset/compose-dev-target.md new file mode 100644 index 0000000..c2dbaed --- /dev/null +++ b/.changeset/compose-dev-target.md @@ -0,0 +1,5 @@ +--- +"seamless-cli": patch +--- + +The generated `docker-compose.yml` now builds the `api` service, and a full-stack `web` service, with `target: dev`. Starting with the templates release that makes the production `runtime` stage the default Docker build target, building without a target would produce the production image under the source bind mount, and the app would fail to start. The SPA `web` service keeps its default nginx stage. diff --git a/src/generators/docker/docker.test.ts b/src/generators/docker/docker.test.ts index cc0e501..bf82aba 100644 --- a/src/generators/docker/docker.test.ts +++ b/src/generators/docker/docker.test.ts @@ -303,7 +303,11 @@ describe("generateDockerCompose", () => { expect(compose).toContain("ISSUER: http://auth:5312"); expect(compose).not.toContain("existing-token"); expect(compose).toContain("JWKS_KID: existing-kid"); - expect(compose).toContain("\n web:\n build: ./web"); + expect(compose).toContain( + "\n api:\n build:\n context: ./api\n target: dev\n", + ); + // The SPA Dockerfiles end with their nginx stage, which is what runs here. + expect(compose).toContain("\n web:\n build: ./web\n"); expect(compose).toContain(`image: ${SEAMLESS_AUTH_ADMIN_DASHBOARD_IMAGE}`); expect(compose).not.toContain("build: ./admin"); expect(compose).toContain("volumes:\n pgdata:"); @@ -700,6 +704,11 @@ describe("generateDockerCompose for a full-stack web app", () => { ); const web = compose.slice(compose.indexOf("\n web:")); + // The template's last stage is production; under the source bind mount only + // the dev stage starts. + expect(web).toContain( + "\n web:\n build:\n context: ./web\n target: dev\n", + ); expect(compose).not.toContain("\n api:"); expect(compose).not.toContain("\n admin:"); expect(web).toContain("- ./web/.env"); diff --git a/src/generators/docker/docker.ts b/src/generators/docker/docker.ts index 87389fa..1c9bd4e 100644 --- a/src/generators/docker/docker.ts +++ b/src/generators/docker/docker.ts @@ -238,10 +238,15 @@ function apiUiOrigins(adminMode: AdminMode): string { return web; } +// The api and full-stack templates end with their production stage, so a plain +// `docker build` never ships a dev server. These services bind-mount the source, +// which would hide that image's compiled output, so they select the dev stage. function apiService(shared: any, adminMode: AdminMode) { return ` api: - build: ./api + build: + context: ./api + target: dev ports: - "127.0.0.1:3000:3000" env_file: @@ -293,7 +298,9 @@ function webService() { function fullStackWebService(shared: any) { return ` web: - build: ./web + build: + context: ./web + target: dev ports: - "127.0.0.1:5173:8080" env_file: