File size: 3,166 Bytes
9f79da5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d25d41
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
# ============================== BASE IMAGE ==============================
# Build Angular UI
FROM node:18-slim AS angular-build

# Build argument: production/development
ARG BUILD_ENV=development

WORKDIR /app

# Copy package files first for better caching
COPY flare-ui/package*.json ./flare-ui/
WORKDIR /app/flare-ui

# Clean npm cache and install with legacy peer deps
RUN npm cache clean --force && npm install --legacy-peer-deps

# Copy the entire flare-ui directory
COPY flare-ui/ ./

# ✅ Clean Angular cache before build
RUN rm -rf .angular/ dist/ node_modules/.cache/

# Build the Angular app based on BUILD_ENV
RUN if [ "$BUILD_ENV" = "development" ] ; then \
    echo "🔧 Building for DEVELOPMENT..." && \
    npm run build:dev -- --output-path=dist/flare-ui ; \
  else \
    echo "🚀 Building for PRODUCTION..." && \
    npm run build:prod -- --output-path=dist/flare-ui ; \
  fi

# Add environment info to container
ENV BUILD_ENVIRONMENT=$BUILD_ENV

# Debug: List directories to see where the build output is
RUN ls -la /app/flare-ui/ && ls -la /app/flare-ui/dist/ || true

# Python runtime
FROM python:3.10-slim

# ====================== SYSTEM-LEVEL DEPENDENCIES ======================
# gcc & friends → bcrypt / uvicorn[standard] gibi C eklentilerini derlemek için
RUN apt-get update \
  && apt-get install -y --no-install-recommends gcc g++ make libffi-dev \
  && rm -rf /var/lib/apt/lists/*

# ============================== WORKDIR ================================
WORKDIR /app

# ===================== HF CACHE & WRITE PERMS ==========================
# Hugging Face Spaces özel dizinleri – yazma izni 777
RUN mkdir -p /app/.cache /tmp/.triton /tmp/torchinductor_cache \
  && chmod -R 777 /app/.cache /tmp/.triton /tmp/torchinductor_cache

ENV HF_HOME=/app/.cache \
    HF_DATASETS_CACHE=/app/.cache \
    HF_HUB_CACHE=/app/.cache \
    TRITON_CACHE_DIR=/tmp/.triton \
    TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_cache

# ============================ REQUIREMENTS =============================
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# ============================== APP CODE ===============================
COPY . .

# ✅ Config dizini ve dosya izinleri - HF Spaces için özel ayarlar
# Tüm app dizinine ve config dosyasına herkesin yazabilmesi için 777
RUN chmod -R 777 /app && \
    touch /app/config/service_config.jsonc && \
    chmod 777 /app/config/service_config.jsonc && \
    # Ayrıca bir .tmp uzantılı dosya da oluştur izinlerle
    touch /app/config/service_config.tmp && \
    chmod 777 /app/config/service_config.tmp

# ✅ Angular build output'u kopyalanıyor
COPY --from=angular-build /app/flare-ui/dist/flare-ui ./static

# Create assets directory if it doesn't exist
RUN mkdir -p ./static/assets

# Debug: Check if static files exist
RUN ls -la ./static/ || echo "No static directory"
RUN ls -la ./static/index.html || echo "No index.html"

# ============================== START CMD ==============================
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]