auto-run drizzle migrations on container startup
This commit is contained in:
@@ -5,7 +5,9 @@ RUN bun install --frozen-lockfile
|
|||||||
|
|
||||||
FROM deps AS builder
|
FROM deps AS builder
|
||||||
ARG NEXT_PUBLIC_API_URL=
|
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 NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||||
|
ENV DATABASE_URL=${DATABASE_URL}
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN mkdir -p public && bun run build
|
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/public ./public
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
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
|
RUN mkdir -p /app/data
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
|
|
||||||
CMD ["bun", "server.js"]
|
CMD ["sh", "-c", "bun x drizzle-kit migrate && bun server.js"]
|
||||||
|
|||||||
@@ -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`).
|
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.
|
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.
|
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.
|
If you use an external Postgres instance, set `DATABASE_URL` explicitly.
|
||||||
Runtime data persists in the `app_data` volume (`/app/data` in container).
|
Runtime data persists in the `app_data` volume (`/app/data` in container).
|
||||||
|
|||||||
Reference in New Issue
Block a user