Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/compose-dev-target.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 10 additions & 1 deletion src/generators/docker/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:");
Expand Down Expand Up @@ -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");
Expand Down
11 changes: 9 additions & 2 deletions src/generators/docker/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down