mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Use custom migration script for self-hosting container
This commit is contained in:
parent
20874486cb
commit
1ed9c6150f
@ -10,7 +10,7 @@
|
||||
"dev": "concurrently -n \"dev,codegen,prisma-studio\" -k \"next dev --turbopack --port 8102\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\"",
|
||||
"build": "pnpm run codegen && next build",
|
||||
"docker-build": "pnpm run codegen && next build --experimental-build-mode compile",
|
||||
"build-self-host-seed-script": "tsup --config prisma/tsup.config.ts",
|
||||
"build-self-host-migration-script": "tsup --config scripts/db-migrations.tsup.config.ts",
|
||||
"analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build",
|
||||
"start": "next start --port 8102",
|
||||
"codegen-prisma": "pnpm run prisma generate",
|
||||
|
||||
@ -6,10 +6,10 @@ const customNoExternal = new Set([
|
||||
...Object.keys(packageJson.dependencies),
|
||||
]);
|
||||
|
||||
// tsup config to build the self-hosting seed script so it can be
|
||||
// tsup config to build the self-hosting migration script so it can be
|
||||
// run in the Docker container with no extra dependencies.
|
||||
export default defineConfig({
|
||||
entry: ['prisma/seed.ts'],
|
||||
entry: ['scripts/db-migrations.ts'],
|
||||
format: ['cjs'],
|
||||
outDir: 'dist',
|
||||
target: 'node22',
|
||||
@ -29,6 +29,7 @@ RUN tsx ./scripts/generate-sdks.ts
|
||||
RUN turbo prune --scope=@stackframe/stack-backend --scope=@stackframe/stack-dashboard --docker
|
||||
|
||||
|
||||
|
||||
# Build stage
|
||||
FROM base AS builder
|
||||
|
||||
@ -55,7 +56,9 @@ ENV NEXT_CONFIG_OUTPUT=standalone
|
||||
RUN pnpm turbo run docker-build --filter=@stackframe/stack-backend... --filter=@stackframe/stack-dashboard...
|
||||
|
||||
# Build the self-host seed script
|
||||
RUN cd apps/backend && pnpm build-self-host-seed-script
|
||||
RUN cd apps/backend && pnpm build-self-host-migration-script
|
||||
|
||||
|
||||
|
||||
# Final image
|
||||
FROM node:${NODE_VERSION}-slim
|
||||
@ -68,14 +71,11 @@ RUN apt-get update && \
|
||||
apt-get install -y openssl socat && \
|
||||
rm -rf /var/lib/apt/lists
|
||||
|
||||
# Install Prisma CLI globally so we can run migrations on startup
|
||||
RUN npm i -g prisma
|
||||
|
||||
# Copy built backend
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/.next/standalone ./
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/.next/static ./apps/backend/.next/static
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/prisma ./apps/backend/prisma
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/dist/seed.js ./apps/backend
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/dist/db-migrations.js ./apps/backend
|
||||
|
||||
# Copy built dashboard
|
||||
COPY --from=builder --chown=node:node /app/apps/dashboard/.next/standalone ./
|
||||
|
||||
@ -37,7 +37,9 @@ if [ "$STACK_SKIP_MIGRATIONS" = "true" ]; then
|
||||
echo "Skipping migrations."
|
||||
else
|
||||
echo "Running migrations..."
|
||||
pnpm run db:migrate
|
||||
cd apps/backend
|
||||
node db-migrations.js migrate
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
if [ "$STACK_SKIP_SEED_SCRIPT" = "true" ]; then
|
||||
@ -45,7 +47,7 @@ if [ "$STACK_SKIP_SEED_SCRIPT" = "true" ]; then
|
||||
else
|
||||
echo "Running seed script..."
|
||||
cd apps/backend
|
||||
node seed.js
|
||||
node db-migrations.js seed
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user