mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
Merge pull request #11 from xCyanGrizzly/copilot/fix-nextjs-deployment-issues
Fix Docker deployment: file permissions, missing env vars, healthcheck timing
This commit is contained in:
12
Dockerfile
12
Dockerfile
@@ -30,19 +30,19 @@ RUN addgroup --system --gid 1001 nodejs && \
|
|||||||
adduser --system --uid 1001 nextjs
|
adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
# Copy public assets
|
# Copy public assets
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||||
|
|
||||||
# Copy prisma schema + migrations for runtime migrate deploy
|
|
||||||
COPY --from=builder /app/prisma ./prisma
|
|
||||||
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
|
||||||
|
|
||||||
# Copy standalone build output
|
# Copy standalone build output
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
|
|
||||||
|
# Copy prisma schema + migrations for runtime migrate deploy
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/prisma.config.ts ./prisma.config.ts
|
||||||
|
|
||||||
# Copy node_modules for prisma CLI (needed for migrate deploy at startup).
|
# Copy node_modules for prisma CLI (needed for migrate deploy at startup).
|
||||||
# Copying the full directory ensures all transitive dependencies are present.
|
# Copying the full directory ensures all transitive dependencies are present.
|
||||||
COPY --from=builder /app/node_modules ./node_modules
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
||||||
# Recreate the .bin/prisma symlink so Node resolves __dirname to prisma/build/,
|
# Recreate the .bin/prisma symlink so Node resolves __dirname to prisma/build/,
|
||||||
# where the WASM files live (COPY dereferences symlinks, breaking WASM resolution)
|
# where the WASM files live (COPY dereferences symlinks, breaking WASM resolution)
|
||||||
RUN mkdir -p ./node_modules/.bin && \
|
RUN mkdir -p ./node_modules/.bin && \
|
||||||
|
|||||||
@@ -10,9 +10,13 @@ services:
|
|||||||
- DATABASE_URL=postgresql://${POSTGRES_USER:-dragons}:${POSTGRES_PASSWORD:-stash}@db:5432/${POSTGRES_DB:-dragonsstash}
|
- DATABASE_URL=postgresql://${POSTGRES_USER:-dragons}:${POSTGRES_PASSWORD:-stash}@db:5432/${POSTGRES_DB:-dragonsstash}
|
||||||
- AUTH_SECRET=${AUTH_SECRET:?Set AUTH_SECRET in .env}
|
- AUTH_SECRET=${AUTH_SECRET:?Set AUTH_SECRET in .env}
|
||||||
- AUTH_TRUST_HOST=true
|
- AUTH_TRUST_HOST=true
|
||||||
|
- AUTH_GITHUB_ID=${AUTH_GITHUB_ID:-}
|
||||||
|
- AUTH_GITHUB_SECRET=${AUTH_GITHUB_SECRET:-}
|
||||||
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
|
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
|
||||||
- TELEGRAM_API_KEY=${TELEGRAM_API_KEY:-}
|
- TELEGRAM_API_KEY=${TELEGRAM_API_KEY:-}
|
||||||
- BOT_TOKEN=${BOT_TOKEN:-}
|
- BOT_TOKEN=${BOT_TOKEN:-}
|
||||||
|
- BOT_USERNAME=${BOT_USERNAME:-}
|
||||||
|
- LOG_LEVEL=${LOG_LEVEL:-info}
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -21,7 +25,7 @@ services:
|
|||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 30s
|
start_period: 60s
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ if [ "$AUTH_SECRET" = "change-me-to-a-random-secret-in-production" ] || [ -z "$A
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Running database migrations..."
|
echo "Running database migrations..."
|
||||||
./node_modules/.bin/prisma migrate deploy
|
if ! ./node_modules/.bin/prisma migrate deploy; then
|
||||||
|
echo "ERROR: Database migration failed. Check DATABASE_URL and database connectivity."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$SEED_DATABASE" = "true" ]; then
|
if [ "$SEED_DATABASE" = "true" ]; then
|
||||||
echo "Seeding database..."
|
echo "Seeding database..."
|
||||||
|
|||||||
Reference in New Issue
Block a user