-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (42 loc) · 1.43 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (42 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
FROM node:22-alpine AS base
# Install OpenSSL for Prisma
RUN apk add --no-cache openssl
WORKDIR /app
# Install dependencies
FROM base AS deps
COPY package.json ./
# Since there is no package-lock.json initially, just install everything
RUN npm install --legacy-peer-deps
# Build the app
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Generate prisma client inside builder
RUN npx prisma generate
# Create the placeholder for data directory and public directory
RUN mkdir -p /app/data/uploads /app/public
ENV NEXT_TELEMETRY_DISABLED=1
ENV DATABASE_URL="file:/app/data/database.db"
# Next.js build
RUN npm run build
# Production image
FROM base AS runner
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV DATABASE_URL="file:/app/data/database.db"
ENV DATA_DIR="/app/data/uploads"
# Set correct permissions
RUN mkdir -p /app/data/uploads
# Copy built application and required production dependencies
RUN mkdir -p /app/public
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# Copy prisma stuff for migrations run at startup
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
EXPOSE 3000
ENV PORT=3000
# Wrapper script to run migrations and start
CMD ["sh", "-c", "npx prisma db push --accept-data-loss && node server.js"]