isam0 commited on
Commit
eb42d7d
·
verified ·
1 Parent(s): fd585b9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -28
Dockerfile CHANGED
@@ -1,69 +1,57 @@
1
- # Nur Brain - Dockerfile for ClawCloud
2
- # Multi-stage build for optimized image
3
-
4
  FROM python:3.11-slim as builder
5
 
6
- # Install build dependencies
7
  RUN apt-get update && apt-get install -y \
8
  build-essential \
9
  cmake \
10
  git \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # Set working directory
14
  WORKDIR /build
15
-
16
- # Copy requirements first for caching
17
  COPY requirements.txt .
18
-
19
- # Install Python dependencies
20
  RUN pip install --no-cache-dir --upgrade pip && \
21
  pip wheel --no-cache-dir --wheel-dir=/wheels -r requirements.txt
22
 
23
- # Production stage
24
  FROM python:3.11-slim
25
 
26
- # Set environment variables
27
  ENV PYTHONDONTWRITEBYTECODE=1 \
28
  PYTHONUNBUFFERED=1 \
29
  PYTHONPATH=/app
30
 
31
- # Install runtime dependencies
32
  RUN apt-get update && apt-get install -y \
33
  libgomp1 \
34
  curl \
35
  && rm -rf /var/lib/apt/lists/* \
36
  && useradd --create-home --shell /bin/bash nur
37
 
38
- # Set working directory
39
  WORKDIR /app
40
 
41
- # Copy wheels from builder
42
  COPY --from=builder /wheels /wheels
43
-
44
- # Install Python packages from wheels
45
  RUN pip install --no-cache-dir --upgrade pip && \
46
  pip install --no-cache-dir /wheels/* && \
47
  rm -rf /wheels
48
 
49
- # Create models directory
50
  RUN mkdir -p /app/models && chown -R nur:nur /app
51
 
52
- # Copy application code
53
  COPY --chown=nur:nur app/ /app/app/
54
 
55
- # Switch to non-root user
 
 
 
 
56
  USER nur
57
 
58
- # Expose port 8080 (ClawCloud requirement)
59
- EXPOSE 8080
60
 
61
- # Health check
62
  HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
63
- CMD curl -f http://localhost:8080/health || exit 1
64
 
65
- # Run the application
66
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]
67
- COPY entrypoint.sh .
68
- RUN chmod +x entrypoint.sh
69
- ENTRYPOINT ["./entrypoint.sh"]
 
1
+ # --- STAGE 1: Builder ---
 
 
2
  FROM python:3.11-slim as builder
3
 
 
4
  RUN apt-get update && apt-get install -y \
5
  build-essential \
6
  cmake \
7
  git \
8
  && rm -rf /var/lib/apt/lists/*
9
 
 
10
  WORKDIR /build
 
 
11
  COPY requirements.txt .
 
 
12
  RUN pip install --no-cache-dir --upgrade pip && \
13
  pip wheel --no-cache-dir --wheel-dir=/wheels -r requirements.txt
14
 
15
+ # --- STAGE 2: Production ---
16
  FROM python:3.11-slim
17
 
 
18
  ENV PYTHONDONTWRITEBYTECODE=1 \
19
  PYTHONUNBUFFERED=1 \
20
  PYTHONPATH=/app
21
 
 
22
  RUN apt-get update && apt-get install -y \
23
  libgomp1 \
24
  curl \
25
  && rm -rf /var/lib/apt/lists/* \
26
  && useradd --create-home --shell /bin/bash nur
27
 
 
28
  WORKDIR /app
29
 
30
+ # Install dependencies from builder
31
  COPY --from=builder /wheels /wheels
 
 
32
  RUN pip install --no-cache-dir --upgrade pip && \
33
  pip install --no-cache-dir /wheels/* && \
34
  rm -rf /wheels
35
 
36
+ # 1. Create directory while ROOT
37
  RUN mkdir -p /app/models && chown -R nur:nur /app
38
 
39
+ # 2. Copy code
40
  COPY --chown=nur:nur app/ /app/app/
41
 
42
+ # 3. CRITICAL: Copy and Fix Entrypoint while ROOT
43
+ COPY entrypoint.sh /app/entrypoint.sh
44
+ RUN chmod +x /app/entrypoint.sh && chown nur:nur /app/entrypoint.sh
45
+
46
+ # 4. Switch to User for safety
47
  USER nur
48
 
49
+ # 5. Hugging Face Port
50
+ EXPOSE 7860
51
 
52
+ # 6. Healthcheck
53
  HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
54
+ CMD curl -f http://localhost:7860/health || exit 1
55
 
56
+ # 7. Start the Brain
57
+ ENTRYPOINT ["/app/entrypoint.sh"]