Files
trendyol-analiz/admin-panel/Dockerfile
furkanyigit34 3867df22aa fix: Dockerfile VITE_API_URL default boş yapıldı (production build)
Ne yaptık:
- admin-panel/Dockerfile: ARG VITE_API_URL=http://localhost:8001 → ARG VITE_API_URL=

Neden yaptık:
- Dockerfile'daki default değer build sırasında .env dosyasını override ediyordu
- Sonuç: production build'e http://127.0.0.1:8001 inline ediliyordu
- Boş string ile nginx relative URL proxy (/api/, /categories/) devreye giriyor

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 00:23:57 +03:00

59 lines
1.6 KiB
Docker

# ============================================
# Stage 1: Build React Application with Vite
# ============================================
FROM node:18-alpine AS builder
# Metadata
LABEL maintainer="Trendyol Product Dashboard"
LABEL description="React frontend build stage"
WORKDIR /app
# Copy package files for dependency installation
COPY package*.json ./
# Install dependencies (with clean npm cache)
RUN npm ci --legacy-peer-deps && \
npm cache clean --force
# Copy source code
COPY . .
# Build argument for API URL (baked into production build)
# Empty = relative URLs, nginx proxies /api/ and /categories/ to backend
ARG VITE_API_URL=
ENV VITE_API_URL=$VITE_API_URL
# Build production bundle
# Output: /app/dist directory with optimized static assets
RUN npm run build
# ============================================
# Stage 2: Serve with Nginx
# ============================================
FROM nginx:1.25-alpine
# Metadata
LABEL maintainer="Trendyol Product Dashboard"
LABEL description="React frontend production server"
# Remove default nginx static assets
RUN rm -rf /usr/share/nginx/html/*
# Copy built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80 for web traffic
EXPOSE 80
# Health check configuration
# Checks if nginx is responding to HTTP requests
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1
# Run nginx in foreground (required for Docker)
CMD ["nginx", "-g", "daemon off;"]