-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
127 lines (104 loc) · 5.31 KB
/
Copy pathDockerfile
File metadata and controls
127 lines (104 loc) · 5.31 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Build stage for monorepo with pnpm
FROM node:20-alpine3.18 AS builder
# Install pnpm directly via npm
RUN npm install -g pnpm@10.10.0
WORKDIR /app
# Accept build arguments for NEXT_PUBLIC_* variables
ARG NEXT_PUBLIC_API_URL
ARG NEXT_PUBLIC_BETTER_AUTH_URL
ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
ARG NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
ARG NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET
ARG NEXT_PUBLIC_GOOGLE_MAPS_API_KEY
ARG NEXT_PUBLIC_GOOGLE_PLACES_API_KEY
ARG MERCADOPAGO_WEBHOOK_SECRET
ARG MERCADOPAGO_CLIENT_ID
ARG MERCADOPAGO_CLIENT_SECRET
ARG MERCADOPAGO_REDIRECT_URI
ARG GROK_API_KEY
# Set build-time environment variables
# Use build args if provided, otherwise use placeholder values
ENV BETTER_AUTH_SECRET=build-time-placeholder-secret-key-for-docker-build
ENV BETTER_AUTH_URL=${NEXT_PUBLIC_BETTER_AUTH_URL:-http://localhost:3000}
ENV NEXT_PUBLIC_BETTER_AUTH_URL=${NEXT_PUBLIC_BETTER_AUTH_URL:-http://localhost:3000}
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:3001}
ENV NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL:-https://placeholder.supabase.co}
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY:-placeholder-anon-key}
ENV NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=${NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME:-placeholder}
ENV NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET=${NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET:-ml_default}
ENV NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=${NEXT_PUBLIC_GOOGLE_MAPS_API_KEY:-placeholder}
ENV NEXT_PUBLIC_GOOGLE_PLACES_API_KEY=${NEXT_PUBLIC_GOOGLE_PLACES_API_KEY:-placeholder}
ENV MERCADOPAGO_WEBHOOK_SECRET=${MERCADOPAGO_WEBHOOK_SECRET:-placeholder-webhook-secret}
ENV MERCADOPAGO_CLIENT_ID=${MERCADOPAGO_CLIENT_ID:-placeholder-mp-client-id}
ENV MERCADOPAGO_CLIENT_SECRET=${MERCADOPAGO_CLIENT_SECRET:-placeholder-mp-client-secret}
ENV MERCADOPAGO_REDIRECT_URI=${MERCADOPAGO_REDIRECT_URI:-https://localhost:3000/api/mercadopago/callback}
ENV GROK_API_KEY=${GROK_API_KEY:-placeholder-grok-key}
ENV RESEND_API_KEY=build-time-placeholder-resend-key
ENV GOOGLE_CLIENT_ID=build-time-placeholder-google-client-id
ENV GOOGLE_CLIENT_SECRET=build-time-placeholder-google-client-secret
ENV MERCADOPAGO_REDIRECT_URI=${MERCADOPAGO_REDIRECT_URI:-http://localhost:3000/configuracion}
ENV DATABASE_URL=postgresql://placeholder:placeholder@localhost:5432/placeholder
ENV DIRECT_URL=postgresql://placeholder:placeholder@localhost:5432/placeholder
ENV UPSTASH_REDIS_REST_URL=https://placeholder.upstash.io
ENV UPSTASH_REDIS_REST_TOKEN=placeholder-token
ENV SERVICE_AUTH_SECRET=build-time-placeholder-service-secret
ENV REVALIDATION_SECRET=build-time-placeholder-revalidation-secret
ENV NEXT_PUBLIC_APP_URL=http://localhost:3000
ENV INTERNAL_API_KEY=build-time-placeholder-internal-api-key
# Copy workspace configuration files
COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./
COPY tsconfig.json turbo.json ./
# Copy package.json files for all workspace packages
COPY packages/db/package.json ./packages/db/
COPY apps/next-frontend/package.json ./apps/next-frontend/
# Copy essential source files for packages that build needs
COPY packages/db/prisma ./packages/db/prisma
COPY packages/db/src ./packages/db/src
COPY packages/db/tsconfig.json ./packages/db/
COPY packages/db/tsup.config.ts ./packages/db/
# Copy next-frontend source
COPY apps/next-frontend ./apps/next-frontend
# Install dependencies using pnpm with workspace support
RUN pnpm install --frozen-lockfile
# Generate Prisma Client
RUN pnpm --filter=@repo/db run db:generate
# Build only the db package and next-frontend
RUN pnpm --filter=@repo/db run build
RUN pnpm --filter=ticketeate run build
# Runner stage
FROM node:20-alpine3.18 AS runner
# Install pnpm directly via npm
RUN npm install -g pnpm@10.10.0
WORKDIR /app
# Copy necessary files from builder
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-workspace.yaml ./
# Copy built packages
COPY --from=builder /app/packages/db/dist ./packages/db/dist
COPY --from=builder /app/packages/db/package.json ./packages/db/
COPY --from=builder /app/packages/db/prisma ./packages/db/prisma
COPY --from=builder /app/apps/next-frontend/.next ./apps/next-frontend/.next
COPY --from=builder /app/apps/next-frontend/public ./apps/next-frontend/public
COPY --from=builder /app/apps/next-frontend/package.json ./apps/next-frontend/
COPY --from=builder /app/apps/next-frontend/next.config.mjs ./apps/next-frontend/
COPY --from=builder /app/apps/next-frontend/content ./apps/next-frontend/content
# Set runtime environment variables with placeholders
# These will be overridden by Parameter Store values at runtime via docker run -e
ENV MERCADOPAGO_CLIENT_ID=placeholder-mp-client-id
ENV MERCADOPAGO_CLIENT_SECRET=placeholder-mp-client-secret
ENV MERCADOPAGO_REDIRECT_URI=http://localhost:3000/api/mercadopago/callback
ENV BETTER_AUTH_SECRET=placeholder-auth-secret
ENV RESEND_API_KEY=placeholder-resend-key
ENV GOOGLE_CLIENT_ID=placeholder-google-client-id
ENV GOOGLE_CLIENT_SECRET=placeholder-google-client-secret
# Install all dependencies first (including dev) to generate Prisma client
RUN pnpm install --frozen-lockfile
# Generate Prisma Client with dev dependencies available
RUN pnpm --filter=@repo/db run db:generate
# Remove dev dependencies and reinstall only production
RUN pnpm install --frozen-lockfile --prod
WORKDIR /app/apps/next-frontend
EXPOSE 3000
CMD ["pnpm", "start"]