-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (34 loc) · 1.07 KB
/
Dockerfile
File metadata and controls
45 lines (34 loc) · 1.07 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
# Use official Node.js image as build environment
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies
COPY package*.json ./
RUN npm install
# Copy source code
COPY . .
# Copy .env file for build-time environment variables
COPY .env .env
# Debug: print .env contents to verify hCaptcha sitekey
RUN cat .env
# Set dummy DATABASE_URL for build (Azure will override at runtime)
ENV DATABASE_URL="postgresql://user:password@localhost:5432/dbname?schema=public"
# Switch Prisma provider to PostgreSQL and generate client
# RUN npm run prisma:postgres
# Run Prisma migrations (if needed)
RUN npm install prisma @prisma/client
RUN npx prisma generate
# Build Next.js app
RUN npm run build
# Production image
FROM node:20-alpine AS runner
WORKDIR /app
# Only copy necessary files for production
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/prisma ./prisma/
# Expose port 3000
EXPOSE 3000
# Start Next.js app
CMD ["npm", "start"]