diff --git a/agenta-web/prod.Dockerfile b/agenta-web/prod.Dockerfile index d90924f5b..7703db122 100644 --- a/agenta-web/prod.Dockerfile +++ b/agenta-web/prod.Dockerfile @@ -1,17 +1,38 @@ -FROM node:20.18-slim +# Stage 1: Build Stage +FROM node:20.18-slim AS builder -# Set the working directory WORKDIR /app # Install only production dependencies COPY package.json package-lock.json* ./ RUN npm ci +# Copy only necessary files +COPY src ./src +COPY public ./public +COPY next.config.js . +COPY tsconfig.json . +COPY postcss.config.js . +COPY tailwind.config.ts . +COPY .env.production . +COPY sentry.* . -COPY . . - -RUN npx next telemetry disable +# Build the Next.js app for production RUN npm run build +# Stage 2: Production Stage +FROM node:20.18-slim AS prod + +WORKDIR /app + +# Copy only the necessary files from the build stage +COPY --from=builder /app/package.json /app/package-lock.json* /app +COPY --from=builder /app/.next /app/.next +COPY --from=builder /app/public /app/public +COPY --from=builder /app/next.config.js /app/tsconfig.json /app/postcss.config.js /app/tailwind.config.ts /app/.env.production /app/sentry.* /app/ + +# Install only production dependencies +RUN npm ci --omit=dev + # Expose the necessary port EXPOSE 3000