-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.render
More file actions
148 lines (117 loc) · 3.99 KB
/
Dockerfile.render
File metadata and controls
148 lines (117 loc) · 3.99 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# ============================================
# Post Express - Render.com Dockerfile
# ============================================
# Solução para Build Args: usar .env file injection
# ============================================
FROM node:18 AS base
# Instalar Chromium + dependências necessárias
RUN apt-get update && apt-get install -y \
chromium \
chromium-driver \
fonts-liberation \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
xdg-utils \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# CRITICAL: Forçar Remotion/Puppeteer a usar Chromium instalado
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
ENV CHROME_BIN=/usr/bin/chromium
ENV REMOTION_BROWSER_EXECUTABLE=/usr/bin/chromium
# ============================================
# STAGE 1: Dependencies
# ============================================
FROM base AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --legacy-peer-deps
# ============================================
# STAGE 2: Build
# ============================================
FROM base AS builder
WORKDIR /app
# Copy dependencies
COPY --from=deps /app/node_modules ./node_modules
# Copy source code
COPY . .
# Set production environment
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# ============================================
# FIX: Carregar variáveis de .env.production.local
# ============================================
# Render pode injetar este arquivo via "Secret Files"
# Ou via script no repositório
# Se .env.production.local existe, carregar variáveis
RUN if [ -f .env.production.local ]; then \
echo "✅ Carregando .env.production.local para build..."; \
export $(cat .env.production.local | grep -v '^#' | xargs); \
else \
echo "⚠️ .env.production.local não encontrado - usando valores default"; \
echo "⚠️ IMPORTANTE: Configure Secret Files no Render!"; \
fi
# Accept build args (fallback se Secret Files não estiver configurado)
ARG SUPABASE_URL
ARG SUPABASE_ANON_KEY
ARG SUPABASE_SERVICE_ROLE_KEY
ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
# Set as environment variables for build
ENV SUPABASE_URL=$SUPABASE_URL
ENV SUPABASE_ANON_KEY=$SUPABASE_ANON_KEY
ENV SUPABASE_SERVICE_ROLE_KEY=$SUPABASE_SERVICE_ROLE_KEY
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
# Debug: Mostrar se variáveis foram carregadas (primeiros caracteres apenas)
RUN echo "🔍 Verificando variáveis de ambiente:" && \
echo " NEXT_PUBLIC_SUPABASE_URL: ${NEXT_PUBLIC_SUPABASE_URL:0:30}..." && \
echo " NEXT_PUBLIC_SUPABASE_ANON_KEY: ${NEXT_PUBLIC_SUPABASE_ANON_KEY:0:20}..."
# Build Next.js
RUN npm run build
# ============================================
# STAGE 3: Runner
# ============================================
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Create non-root user
RUN groupadd --system --gid 1001 nodejs
RUN useradd --system --uid 1001 nextjs
# Copy node_modules
COPY --from=builder /app/node_modules ./node_modules
# Copy package files
COPY --from=builder /app/package*.json ./
# Copy built Next.js app
COPY --from=builder /app/.next ./.next
# Copy source files needed at runtime
COPY --from=builder /app/lib ./lib
COPY --from=builder /app/types ./types
COPY --from=builder /app/components ./components
COPY --from=builder /app/hooks ./hooks
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
# Copy Remotion bundle
COPY --from=builder /app/.remotion-bundle ./.remotion-bundle
COPY --from=builder /app/remotion ./remotion
COPY --from=builder /app/templates ./templates
# Set ownership
RUN chown -R nextjs:nodejs /app
USER nextjs
# Expose port
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Start Next.js server
CMD ["npm", "start"]