a13992e387
drizzle-kit migrate exits 0 even when migrations fail, so the server would start on a broken schema. The custom migrate.ts uses drizzle-orm's programmatic migrator and calls process.exit(1) on failure, which prevents the server from starting and makes failures visible in Coolify. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
1.2 KiB
Docker
40 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
FROM oven/bun:1 AS base
|
|
WORKDIR /usr/src/app
|
|
|
|
FROM base AS install
|
|
COPY package.json bun.lock ./
|
|
RUN bun install --frozen-lockfile
|
|
|
|
FROM base AS build
|
|
COPY --from=install /usr/src/app/node_modules node_modules
|
|
COPY . .
|
|
|
|
ENV NODE_ENV=production \
|
|
SKIP_ENV_VALIDATION=1 \
|
|
NODE_OPTIONS=--max-old-space-size=4096 \
|
|
BETTER_AUTH_URL=http://localhost:3000 \
|
|
AUTH_SECRET=docker-build-placeholder-secret-do-not-use \
|
|
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
|
|
RUN bun run build
|
|
|
|
FROM base AS release
|
|
ENV NODE_ENV=production \
|
|
PORT=3000 \
|
|
HOSTNAME=0.0.0.0
|
|
|
|
COPY --from=build /usr/src/app/.next/standalone ./
|
|
COPY --from=build /usr/src/app/.next/static ./.next/static
|
|
COPY --from=build /usr/src/app/public ./public
|
|
COPY --from=install /usr/src/app/node_modules node_modules
|
|
COPY --from=build /usr/src/app/package.json ./package.json
|
|
COPY --from=build /usr/src/app/drizzle.config.ts ./drizzle.config.ts
|
|
COPY --from=build /usr/src/app/drizzle ./drizzle
|
|
COPY --from=build /usr/src/app/src/server/db/migrate.ts ./migrate.ts
|
|
|
|
RUN chmod -R a+rX drizzle public migrate.ts
|
|
|
|
USER bun
|
|
EXPOSE 3000
|
|
CMD ["sh", "-c", "bun migrate.ts && bun server.js"]
|