minhajHP commited on
Commit
11c1930
·
1 Parent(s): 2593e90

Add Docker configuration files for Hugging Face deployment

Browse files
Files changed (5) hide show
  1. .dockerignore +99 -0
  2. .gitignore +0 -4
  3. Dockerfile +62 -0
  4. Dockerfile.simple +47 -0
  5. Dockerfile.ubuntu +57 -0
.dockerignore ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Node.js and npm
2
+ node_modules/
3
+ npm-debug.log*
4
+ yarn-debug.log*
5
+ yarn-error.log*
6
+
7
+ # Python
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+ *.so
12
+ .Python
13
+ env/
14
+ venv/
15
+ ENV/
16
+ env.bak/
17
+ venv.bak/
18
+ pip-log.txt
19
+ pip-delete-this-directory.txt
20
+
21
+ # Virtual environments
22
+ .env
23
+ .venv
24
+
25
+ # IDE and editor files
26
+ .vscode/
27
+ .idea/
28
+ *.swp
29
+ *.swo
30
+ *~
31
+ .DS_Store
32
+
33
+ # Git
34
+ .git/
35
+ .gitignore
36
+
37
+ # Docker
38
+ Dockerfile*
39
+ docker-compose*
40
+ .dockerignore
41
+
42
+ # Documentation and markdown (except README)
43
+ *.md
44
+ !README.md
45
+
46
+ # Jupyter notebooks
47
+ .ipynb_checkpoints/
48
+ *.ipynb
49
+
50
+ # Logs
51
+ *.log
52
+ logs/
53
+
54
+ # Temporary files
55
+ .tmp/
56
+ temp/
57
+
58
+ # OS generated files
59
+ Thumbs.db
60
+ .DS_Store
61
+
62
+ # Build artifacts that should be rebuilt
63
+ frontend/build/
64
+ frontend/node_modules/
65
+
66
+ # Testing
67
+ coverage/
68
+ .nyc_output/
69
+ .coverage
70
+
71
+ # Local development files
72
+ .pytest_cache/
73
+ .cache/
74
+
75
+ # Environment variables
76
+ .env
77
+ .env.local
78
+ .env.development.local
79
+ .env.test.local
80
+ .env.production.local
81
+
82
+ # Backup files
83
+ *.backup
84
+ *.bak
85
+
86
+ # Distribution / packaging
87
+ .Python
88
+ build/
89
+ develop-eggs/
90
+ dist/
91
+ downloads/
92
+ eggs/
93
+ .eggs/
94
+ lib/
95
+ lib64/
96
+ parts/
97
+ sdist/
98
+ var/
99
+ wheels/
.gitignore CHANGED
@@ -254,10 +254,6 @@ output/
254
  results/
255
  experiments/
256
 
257
- # Docker
258
- .dockerignore
259
- Dockerfile*
260
- docker-compose*.yml
261
 
262
  # Keep essential config files
263
  !package.json
 
254
  results/
255
  experiments/
256
 
 
 
 
 
257
 
258
  # Keep essential config files
259
  !package.json
Dockerfile ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Multi-stage build for RecSys-HP Recommendation System
2
+ # This Dockerfile builds both the React frontend and Python backend into a single container
3
+
4
+ # Stage 1: Build React Frontend
5
+ FROM node:18-alpine AS frontend-builder
6
+
7
+ WORKDIR /app/frontend
8
+
9
+ # Copy frontend package files
10
+ COPY frontend/package*.json ./
11
+
12
+ # Install npm dependencies
13
+ RUN npm ci --only=production --silent
14
+
15
+ # Copy frontend source code
16
+ COPY frontend/ ./
17
+
18
+ # Build React app for production
19
+ RUN npm run build
20
+
21
+ # Stage 2: Main Python Application
22
+ FROM python:3.10-slim
23
+
24
+ # Set environment variables
25
+ ENV PYTHONDONTWRITEBYTECODE=1
26
+ ENV PYTHONUNBUFFERED=1
27
+ ENV DEBIAN_FRONTEND=noninteractive
28
+
29
+ # Install system dependencies
30
+ RUN apt-get update && apt-get install -y \
31
+ build-essential \
32
+ curl \
33
+ && rm -rf /var/lib/apt/lists/*
34
+
35
+ # Set working directory
36
+ WORKDIR /app
37
+
38
+ # Copy Python requirements and install dependencies
39
+ COPY requirements.txt .
40
+ RUN pip install --no-cache-dir -r requirements.txt
41
+
42
+ # Copy the entire application
43
+ COPY . .
44
+
45
+ # Copy built React frontend from previous stage
46
+ COPY --from=frontend-builder /app/frontend/build ./frontend/build
47
+
48
+ # Create directories for artifacts if they don't exist
49
+ RUN mkdir -p src/artifacts datasets
50
+
51
+ # Make sure the API directory is accessible
52
+ WORKDIR /app
53
+
54
+ # Expose port
55
+ EXPOSE 8000
56
+
57
+ # Health check
58
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
59
+ CMD curl -f http://localhost:8000/health || exit 1
60
+
61
+ # Start the application
62
+ CMD ["python", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
Dockerfile.simple ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Simple single-stage build for RecSys-HP (if multi-stage fails)
2
+ FROM python:3.10-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+ ENV DEBIAN_FRONTEND=noninteractive
8
+
9
+ # Install system dependencies including Node.js
10
+ RUN apt-get update && apt-get install -y \
11
+ build-essential \
12
+ curl \
13
+ ca-certificates \
14
+ gnupg \
15
+ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
16
+ && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
17
+ && apt-get update && apt-get install -y nodejs \
18
+ && rm -rf /var/lib/apt/lists/*
19
+
20
+ # Set working directory
21
+ WORKDIR /app
22
+
23
+ # Copy Python requirements and install dependencies
24
+ COPY requirements.txt .
25
+ RUN pip install --no-cache-dir -r requirements.txt
26
+
27
+ # Copy frontend and build it
28
+ COPY frontend/ ./frontend/
29
+ WORKDIR /app/frontend
30
+ RUN npm install && npm run build
31
+
32
+ # Copy the rest of the application
33
+ WORKDIR /app
34
+ COPY . .
35
+
36
+ # Create directories for artifacts if they don't exist
37
+ RUN mkdir -p src/artifacts datasets
38
+
39
+ # Expose port
40
+ EXPOSE 8000
41
+
42
+ # Health check
43
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
44
+ CMD curl -f http://localhost:8000/health || exit 1
45
+
46
+ # Start the application
47
+ CMD ["python", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
Dockerfile.ubuntu ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ubuntu-based build for RecSys-HP (for network connectivity issues)
2
+ FROM ubuntu:20.04
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+ ENV DEBIAN_FRONTEND=noninteractive
8
+
9
+ # Install system dependencies
10
+ RUN apt-get update && apt-get install -y \
11
+ python3 \
12
+ python3-pip \
13
+ python3-dev \
14
+ build-essential \
15
+ curl \
16
+ ca-certificates \
17
+ gnupg \
18
+ software-properties-common \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Install Node.js
22
+ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
23
+ && apt-get install -y nodejs
24
+
25
+ # Create symlink for python
26
+ RUN ln -s /usr/bin/python3 /usr/bin/python
27
+
28
+ # Set working directory
29
+ WORKDIR /app
30
+
31
+ # Copy Python requirements and install dependencies
32
+ COPY requirements.txt .
33
+ RUN python3 -m pip install --upgrade pip
34
+ RUN python3 -m pip install --no-cache-dir -r requirements.txt
35
+
36
+ # Copy frontend and build it
37
+ COPY frontend/ ./frontend/
38
+ WORKDIR /app/frontend
39
+ RUN npm install
40
+ RUN npm run build
41
+
42
+ # Copy the rest of the application
43
+ WORKDIR /app
44
+ COPY . .
45
+
46
+ # Create directories for artifacts if they don't exist
47
+ RUN mkdir -p src/artifacts datasets
48
+
49
+ # Expose port
50
+ EXPOSE 8000
51
+
52
+ # Health check
53
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
54
+ CMD curl -f http://localhost:8000/health || exit 1
55
+
56
+ # Start the application
57
+ CMD ["python3", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]