CodebaseAi commited on
Commit
4252e58
·
1 Parent(s): 87f8e11

Fixed versions

Browse files
Files changed (3) hide show
  1. Dockerfile +19 -11
  2. app.py +3 -0
  3. requirements.txt +25 -42
Dockerfile CHANGED
@@ -1,29 +1,37 @@
1
- # 1. Use a standard Python image
2
  FROM python:3.9-slim
3
 
4
- # 2. Install system-level tools needed for Scapy and Network monitoring
 
 
 
 
5
  RUN apt-get update && apt-get install -y \
6
  libpcap-dev \
7
  gcc \
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- # 3. Create a non-root user for security (Hugging Face requirement)
11
  RUN useradd -m -u 1000 user
12
  USER user
13
- ENV PATH="/home/user/.local/bin:${PATH}"
 
14
 
15
- # 4. Set the working directory
16
- WORKDIR /home/user/app
17
 
18
- # 5. Copy and install requirements
19
  COPY --chown=user requirements.txt .
 
 
 
20
  RUN pip install --no-cache-dir --user -r requirements.txt
21
 
22
- # 6. Copy the rest of your code
23
  COPY --chown=user . .
24
 
25
- # 7. Hugging Face uses port 7860 by default
26
  EXPOSE 7860
27
 
28
- # 8. Start the server using Gunicorn + Eventlet (Best for SocketIO)
29
- CMD ["gunicorn", "--worker-class", "eventlet", "-w", "1", "--bind", "0.0.0.0:7860", "app:app"]
 
1
+ # Use a slim but stable version of Python
2
  FROM python:3.9-slim
3
 
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+
8
+ # Install system dependencies for network capturing and building
9
  RUN apt-get update && apt-get install -y \
10
  libpcap-dev \
11
  gcc \
12
+ python3-dev \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Create a non-root user (Hugging Face requirement)
16
  RUN useradd -m -u 1000 user
17
  USER user
18
+ ENV HOME=/home/user \
19
+ PATH=/home/user/.local/bin:$PATH
20
 
21
+ WORKDIR $HOME/app
 
22
 
23
+ # Copy requirements first to leverage Docker cache
24
  COPY --chown=user requirements.txt .
25
+
26
+ # Install dependencies
27
+ # We use --no-cache-dir to keep the image small
28
  RUN pip install --no-cache-dir --user -r requirements.txt
29
 
30
+ # Copy the rest of the application
31
  COPY --chown=user . .
32
 
33
+ # Expose the HF default port
34
  EXPOSE 7860
35
 
36
+ # Start the application
37
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import logging
2
  from flask import Flask, jsonify
3
  from flask_cors import CORS
 
1
+ import eventlet
2
+ eventlet.monkey_patch()
3
+
4
  import logging
5
  from flask import Flask, jsonify
6
  from flask_cors import CORS
requirements.txt CHANGED
@@ -1,45 +1,28 @@
1
- appdirs==1.4.4
2
- blinker==1.9.0
3
- click==8.3.0
4
- colorama==0.4.6
5
- contourpy==1.3.3
6
- cycler==0.12.1
7
- Flask==3.1.2
8
- flask-cors==6.0.1
9
- fonttools==4.60.1
10
- itsdangerous==2.2.0
11
- Jinja2==3.1.6
12
- joblib==1.5.2
13
- kiwisolver==1.4.9
14
- lightgbm==4.6.0
15
- lxml==6.0.2
16
- MarkupSafe==3.0.3
17
- matplotlib==3.10.7
18
- numpy==2.3.4
19
- packaging==25.0
20
- pandas==2.3.3
21
- pillow==12.0.0
22
- pyparsing==3.2.5
23
- pyshark==0.6
24
- python-dateutil==2.9.0.post0
25
- pytz==2025.2
26
- scapy==2.6.1
27
- scikit-learn==1.7.2
28
- scipy==1.16.3
29
- seaborn==0.13.2
30
- six==1.17.0
31
- termcolor==3.2.0
32
- threadpoolctl==3.6.0
33
- tzdata==2025.2
34
- Werkzeug==3.1.3
35
- gunicorn
36
- gevent
37
- gevent-websocket
38
- Flask-SocketIO
39
- fpdf
40
  requests
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  psutil
 
 
42
  groq
43
- gunicorn
44
- eventlet
45
- huggingface_hub
 
 
1
+ # Web & Server
2
+ Flask==3.0.3
3
+ flask-cors==4.0.1
4
+ Flask-SocketIO==5.3.6
5
+ gunicorn==22.0.0
6
+ eventlet==0.35.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  requests
8
+
9
+ # Machine Learning & Data (Stable Versions)
10
+ numpy<2.0.0
11
+ pandas<2.2.0
12
+ scikit-learn
13
+ scipy
14
+ joblib
15
+ lightgbm
16
+ huggingface_hub
17
+
18
+ # Network & Analysis
19
+ scapy==2.5.0
20
+ pyshark
21
  psutil
22
+
23
+ # Utils & AI
24
  groq
25
+ fpdf
26
+ matplotlib
27
+ seaborn
28
+ python-dateutil