Skip to content

Commit a23046b

Browse files
committed
fix(docker): run database migrations before server starts
This ensures migrations are applied before Next.js app preparation, preventing "column does not exist" errors when new columns are added to the schema. Changes: - Add migration.ts as esbuild entry point (compiles to dist/migration.mjs) - Update Dockerfile CMD to run migrations before server start - Update Dockerfile.cloud with same migration approach The proper startup order is now: 1. Run dist/migration.mjs (applies pending migrations) 2. Run pnpm start (starts the server) This is the standard pattern for production deployments where database schema must be updated before the application starts making queries.
1 parent 9b198f4 commit a23046b

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ RUN curl -sSL https://railpack.com/install.sh | bash
6565
COPY --from=buildpacksio/pack:0.35.0 /usr/local/bin/pack /usr/local/bin/pack
6666

6767
EXPOSE 3000
68-
CMD [ "pnpm", "start" ]
68+
# Run database migrations before starting the server
69+
CMD node -r dotenv/config dist/migration.mjs && pnpm start

Dockerfile.cloud

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ RUN curl https://rclone.org/install.sh | bash
6060
RUN pnpm install -g tsx
6161

6262
EXPOSE 3000
63-
CMD [ "pnpm", "start" ]
63+
# Run database migrations before starting the server
64+
CMD node -r dotenv/config dist/migration.mjs && pnpm start

apps/dokploy/esbuild.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ try {
2424
.build({
2525
entryPoints: {
2626
server: "server/server.ts",
27+
migration: "migration.ts",
2728
"reset-password": "reset-password.ts",
2829
"reset-2fa": "reset-2fa.ts",
2930
},

0 commit comments

Comments
 (0)