migrator before runner
This commit is contained in:
parent
d4d68b0767
commit
5c1f7718e1
19
Dockerfile
19
Dockerfile
@ -33,9 +33,20 @@ RUN pnpm install
|
||||
COPY --from=builder /app/out/full/ .
|
||||
RUN pnpm turbo run build
|
||||
|
||||
# Add between build and runner stages:
|
||||
FROM installer AS migrator
|
||||
WORKDIR /app
|
||||
# Copy migration files
|
||||
COPY --from=installer /app/packages/db/migrations ./packages/db/migrations
|
||||
COPY --from=installer /app/packages/db/migrate.ts ./packages/db/migrate.ts
|
||||
# Run migrations
|
||||
RUN npx packages/db/migrate.ts
|
||||
|
||||
# Then continue with the runner stage as before
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
RUN corepack enable
|
||||
RUN apk add --no-cache postgresql
|
||||
|
||||
# Don't run production as root
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
@ -48,13 +59,5 @@ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
|
||||
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
|
||||
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
|
||||
|
||||
# # Handle db migrations
|
||||
# COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
|
||||
# COPY --from=builder --chown=nextjs:nodejs /app/packages/db ./packages/db
|
||||
|
||||
# RUN ["pnpm", "--filter=@lifetracker/db", "install"]
|
||||
# RUN ["pnpm", "--filter=@lifetracker/db", "generate"]
|
||||
# RUN ["pnpm", "--filter=@lifetracker/db", "migrate"]
|
||||
|
||||
EXPOSE 3000
|
||||
CMD node apps/web/server.js
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { db } from "./drizzle";
|
||||
|
||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||
|
||||
async function runMigrations() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user