@@ -4,24 +4,32 @@ FROM node:20.15.1-alpine AS builder
44WORKDIR /app
55
66# Define build arguments with default values
7- ARG NEXT_PUBLIC_API_URL=https://api-evoai.evoapicloud.com
7+ ARG NEXT_PUBLIC_API_URL=https://api.evo-ai.co
88
9- # Instalar pnpm globalmente
109RUN npm install -g pnpm
1110
12- # Install dependencies first ( caching)
11+ # Copy package files first for better caching
1312COPY package.json pnpm-lock.yaml ./
13+
14+ # Copy configuration files that are needed for dependency resolution
15+ COPY tsconfig.json ./
16+ COPY next.config.mjs ./
17+ COPY tailwind.config.ts ./
18+ COPY postcss.config.mjs ./
19+ COPY components.json ./
20+
21+ # Install dependencies
1422RUN pnpm install --no-frozen-lockfile
1523
16- # Instalar explicitamente o next-runtime-env
1724RUN pnpm add next-runtime-env
1825
19- # Copy source code
26+ # Copy all source code
2027COPY . .
2128
2229# Set environment variables from build arguments
2330ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
2431
32+ # Build the application
2533RUN pnpm run build
2634
2735# Production stage
@@ -32,14 +40,12 @@ WORKDIR /app
3240# Define build arguments again for the runner stage
3341ARG NEXT_PUBLIC_API_URL=https://api-evoai.evoapicloud.com
3442
35- # Instalar pnpm globalmente
3643RUN npm install -g pnpm
3744
3845# Install production dependencies only
3946COPY package.json pnpm-lock.yaml ./
4047RUN pnpm install --prod --no-frozen-lockfile
4148
42- # Instalar explicitamente o next-runtime-env na produção
4349RUN pnpm add next-runtime-env
4450
4551# Copy built assets from builder
@@ -52,7 +58,7 @@ ENV NODE_ENV=production
5258ENV PORT=3000
5359ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
5460
55- # Script to replace environment variables at runtime - create it diretamente no container
61+ # Script to replace environment variables at runtime
5662COPY docker-entrypoint.sh ./
5763RUN chmod +x ./docker-entrypoint.sh
5864
0 commit comments