diff --git a/Dockerfile b/Dockerfile index e7942cb..39402c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,9 @@ RUN bun install --frozen-lockfile FROM deps AS builder ARG NEXT_PUBLIC_API_URL= +ARG DATABASE_URL=postgres://postgres:postgres@localhost:5432/fiscal_clone ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} +ENV DATABASE_URL=${DATABASE_URL} ENV NEXT_TELEMETRY_DISABLED=1 COPY . . RUN mkdir -p public && bun run build @@ -21,10 +23,12 @@ ENV NEXT_TELEMETRY_DISABLED=1 COPY --from=builder /app/public ./public COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/drizzle ./drizzle +COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts RUN mkdir -p /app/data EXPOSE 3000 ENV PORT=3000 -CMD ["bun", "server.js"] +CMD ["sh", "-c", "bun x drizzle-kit migrate && bun server.js"] diff --git a/README.md b/README.md index 18a2f95..3f1d280 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ docker compose up --build -d For local Docker, host port mapping comes from `docker-compose.override.yml` (default `http://localhost:3000`, configurable via `APP_PORT`). The base Docker Compose now includes an internal PostgreSQL service (`postgres`) used by Better Auth by default. +On container startup, the app now applies Drizzle migrations automatically before launching Next.js. For Coolify/remote Docker Compose, only app container port `3000` is exposed internally (no fixed host port bind), avoiding host port collisions. If you use an external Postgres instance, set `DATABASE_URL` explicitly. Runtime data persists in the `app_data` volume (`/app/data` in container).