-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
97 lines (76 loc) · 2.87 KB
/
Dockerfile
File metadata and controls
97 lines (76 loc) · 2.87 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Use the official Node.js runtime as base image
FROM node:18-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy package files from frontend directory (including pnpm-lock.yaml)
COPY frontend/package.json frontend/pnpm-lock.yaml ./
# Install dependencies using pnpm with frozen lockfile
RUN pnpm install --frozen-lockfile
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
# Install pnpm in builder stage
RUN npm install -g pnpm
COPY --from=deps /app/node_modules ./node_modules
COPY frontend/ .
# Accept build arguments
ARG OPENAI_API_KEY
ARG GROQ_API_KEY
ARG GITHUB_TOKEN
ARG ELEVENLABS_API_KEY
ARG ELEVENLABS_AGENT_ID
ARG ELEVENLABS_AGENT_PHONE_ID
ARG TWILIO_ACCOUNT_SID
ARG TWILIO_AUTH_TOKEN
ARG TWILIO_PHONE_NUMBER
ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
ARG SUPABASE_SERVICE_ROLE_KEY
# Set environment variables for build
ENV OPENAI_API_KEY=$OPENAI_API_KEY
ENV GROQ_API_KEY=$GROQ_API_KEY
ENV GITHUB_TOKEN=$GITHUB_TOKEN
ENV ELEVENLABS_API_KEY=$ELEVENLABS_API_KEY
ENV ELEVENLABS_AGENT_ID=$ELEVENLABS_AGENT_ID
ENV ELEVENLABS_AGENT_PHONE_ID=$ELEVENLABS_AGENT_PHONE_ID
ENV TWILIO_ACCOUNT_SID=$TWILIO_ACCOUNT_SID
ENV TWILIO_AUTH_TOKEN=$TWILIO_AUTH_TOKEN
ENV TWILIO_PHONE_NUMBER=$TWILIO_PHONE_NUMBER
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
ENV SUPABASE_SERVICE_ROLE_KEY=$SUPABASE_SERVICE_ROLE_KEY
# Build the Next.js app using pnpm
RUN pnpm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1
# Install GraphicsMagick and Ghostscript for PDF processing
RUN apk add --no-cache graphicsmagick ghostscript
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy the public folder from frontend
COPY --from=builder /app/public ./public
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next
# Create temp directory for CV processing and give nextjs user write permissions
RUN mkdir -p /app/temp_images && chown nextjs:nodejs /app/temp_images
RUN chmod 755 /app && chmod 755 /app/temp_images
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
# set hostname to localhost
ENV HOSTNAME "0.0.0.0"
CMD ["node", "server.js"]