Skip to content

chore: optimize docker image size (50% reduction)#483

Merged
johanohly merged 4 commits intomainfrom
feat/adapter-node
Feb 23, 2026
Merged

chore: optimize docker image size (50% reduction)#483
johanohly merged 4 commits intomainfrom
feat/adapter-node

Conversation

@johanohly
Copy link
Owner

@johanohly johanohly commented Feb 23, 2026

Down from around 330MB compressed to 140MB compressed


Summary by cubic

Reduced Docker image size by ~50% (≈330MB → ≈140MB) by moving Bun to build-only and running the app on node:22-slim. Also replaced Prisma CLI migrations with a lightweight Node runner and switched to @sveltejs/adapter-node.

  • Refactors

    • Final stage uses node:22-slim; Bun is only used to build.
    • Switched to @sveltejs/adapter-node and removed svelte-adapter-bun.
    • Added docker/migrate.js to apply SQL in prisma/migrations and track state in _prisma_migrations; entrypoint now runs on Node and drops the previous arm64 workaround.
    • Trimmed production dependencies and cleaned lockfile to reduce footprint; minor docs tweaks to simplify ORIGIN handling.
  • Migration

    • Ensure DB_URL is set; migrations auto-run at startup via docker/migrate.js.
    • Existing prisma/migrations SQL files are used as before; no other changes required.

Written for commit 4d98681. Summary will update on new commits.

@sonarqubecloud
Copy link

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 8 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docker/migrate.js">

<violation number="1" location="docker/migrate.js:33">
P1: Missing PostgreSQL advisory lock — concurrent container starts can cause duplicate or conflicting migration runs.

Prisma's `migrate deploy` acquires `pg_advisory_lock(72707369)` before checking/applying migrations to serialize concurrent runners. Without this, two containers starting simultaneously will both see the same pending migrations and race to apply them, which can corrupt the schema or cause errors.

Acquire the lock right after `CREATE TABLE` and it will auto-release when the connection ends in the `finally` block.</violation>

<violation number="2" location="docker/migrate.js:70">
P2: If `ROLLBACK` itself fails (e.g., connection lost), the original migration error is swallowed. Wrap the `ROLLBACK` in a try/catch to preserve the original error for debugging.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@johanohly johanohly merged commit 13faa0f into main Feb 23, 2026
7 of 9 checks passed
@johanohly johanohly deleted the feat/adapter-node branch February 23, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant