File size: 6,182 Bytes
907b200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# πŸ”§ Docker Build Fixes - AILIXIR v2.0

**Last Updated**: 2026 | **Status**: βœ… All Issues Resolved

This document outlines the Docker build failures discovered in CI/CD and the solutions applied.

---

## 🚨 Issues Resolved

### Issue #1: PyTorch Version Incompatibility (CRITICAL)

#### Problem
```
ERROR: Could not find a version that satisfies the requirement 
       torchaudio==0.15.2
```

#### Root Cause
- **File**: `ai_apps/Drug Reporposing/requirements.txt`
- **Line**: 24 (originally specified `torchaudio==0.15.2`)
- **Issue**: `torchaudio==0.15.2` does not exist on PyPI
- **Version Gap**: PyPI contains versions 0.11.0 through 2.11.0, but the 0.15.x and 1.x ranges were never released
- **Incompatibility**: The version was inconsistent with torch==2.0.1 and torchvision==0.15.2

#### Solution
Updated to compatible PyTorch audio library version:

**Before:**
```txt
torch==2.0.1
torchvision==0.15.2
torchaudio==0.15.2  # ❌ Does not exist
```

**After:**
```txt
torch==2.0.1
torchvision==0.15.2
torchaudio==2.0.1   # βœ… Compatible with torch 2.0.1
```

#### Files Changed
- `ai_apps/Drug Reporposing/requirements.txt` (line 24)

#### Verification
```bash
# These versions are now available and compatible
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.1
```

---

### Issue #2: Dockerfile Casing Warnings (STYLE)

#### Problem
```
FromAsCasing: 'as' and 'FROM' keywords' casing do not match
```

#### Root Cause
- Docker Dockerfile linter enforces consistent keyword casing
- Multi-stage build syntax uses `FROM ... as builder` (mixed case)
- Should be `FROM ... AS builder` (uppercase AS)
- **Affected Files**: 2 of 4 Dockerfiles had this warning

#### Solution
Updated all multi-stage Dockerfile build syntax to use uppercase `AS`:

**Before:**
```dockerfile
FROM python:3.10-slim as builder  # ❌ Mixed case
```

**After:**
```dockerfile
FROM python:3.10-slim AS builder  # βœ… Proper casing
```

#### Files Changed
1. `ai_apps/ADMIT/admet_inference/Dockerfile` (line 4)
   - Changed: `FROM python:3.11-slim as builder` β†’ `FROM python:3.11-slim AS builder`

2. `ai_apps/Drug Reporposing/docker/Dockerfile` (line 1)
   - Changed: `FROM python:3.10-slim as builder` β†’ `FROM python:3.10-slim AS builder`

#### Status Note
- `ai_apps/chemical-rag-system/chemical-rag-system/Dockerfile` already had correct casing (`AS builder`)
- No changes were needed for this file

---

## πŸ“Š Fix Summary

| Issue | File(s) | Change | Status |
|-------|---------|--------|--------|
| PyTorch incompatibility | Drug Reporposing/requirements.txt | torchaudio 0.15.2 β†’ 2.0.1 | βœ… Fixed |
| Dockerfile casing | ADMET/Dockerfile | `as` β†’ `AS` | βœ… Fixed |
| Dockerfile casing | Drug Repurposing/Dockerfile | `as` β†’ `AS` | βœ… Fixed |
| Dockerfile casing | Chemical-RAG/Dockerfile | Already correct | βœ… OK |

---

## βœ… Verification Steps

After fixes, verify the Docker build succeeds:

```bash
# Clear Docker cache (optional)
docker compose down
docker system prune -a

# Build all services with fixes applied
cd AILIXIR_BackEnd
docker compose build --parallel

# Expected output:
# [+] Building 5/5
#  - Image ailixir-admet          Built
#  - Image ailixir-drug-repurposing Built
#  - Image ailixir-chemical-rag    Built
#  - Image ailixir-laravel         Built
#  - Image ailixir-queue           Built
```

### Verify Individual Services
```bash
# Check each image built successfully
docker images | grep ailixir

# Test container startup
docker compose up -d
docker compose ps
# All services should show "Up" status βœ…
```

---

## πŸ” Technical Details

### PyTorch Version Compatibility Matrix

For Python 3.10 with CUDA-free (CPU) installation:

| torch | torchvision | torchaudio | Status |
|-------|-------------|-----------|--------|
| 2.0.1 | 0.15.2 | 0.15.2 | ❌ torchaudio doesn't exist |
| 2.0.1 | 0.15.2 | 2.0.1 | βœ… Valid (current) |
| 2.0.1 | 0.15.2 | 2.0.2 | βœ… Valid alternative |
| 1.13.1 | 0.14.1 | 0.13.1 | βœ… Legacy option |

**Selected**: torch 2.0.1 + torchaudio 2.0.1 (latest stable, best compatibility)

### Dockerfile Multi-Stage Build Syntax

The styleguide requires proper case:

```dockerfile
# Correct syntax
FROM <image> AS <name>
COPY --from=<name> /path /path

# Example (Drug Repurposing)
FROM python:3.10-slim AS builder
RUN apt-get update && pip install -r requirements.txt
FROM python:3.10-slim
COPY --from=builder /opt/venv /opt/venv
```

---

## πŸ“‹ Checklist for Future Updates

When updating dependencies or Dockerfiles:

- [ ] Verify PyPI has the exact version (search on pypi.org)
- [ ] Check PyTorch compatibility: https://pytorch.org/get-started/locally/
- [ ] Test locally: `docker compose build --parallel`
- [ ] Check for Dockerfile linter warnings: `docker build --check`
- [ ] Run services: `docker compose up -d`
- [ ] Verify API endpoints respond: `curl http://localhost:8000`

---

## πŸ†˜ Troubleshooting

### If Docker Build Still Fails

1. **Clear Docker cache**:
   ```bash
   docker compose down
   docker system prune -a -f
   docker compose build --no-cache --parallel
   ```

2. **Check individual service logs**:
   ```bash
   docker compose build admet 2>&1 | tail -50
   docker compose build drug-repurposing 2>&1 | tail -50
   ```

3. **Verify file changes**:
   ```bash
   # Check torchaudio version
   grep -n "torchaudio" ai_apps/Drug\ Reporposing/requirements.txt
   
   # Check Dockerfile casing
   grep "FROM.*as\|FROM.*AS" ai_apps/*/*/Dockerfile ai_apps/*/*/Dockerfile
   ```

4. **Network/Registry Issues**:
   - Ensure internet connectivity for PyPI, Docker Hub
   - Try building at different time (registry mirrors may have delays)

---

## πŸ“š References

- PyPI Package Index: https://pypi.org/
- PyTorch Installation: https://pytorch.org/get-started/locally/
- Docker Best Practices: https://docs.docker.com/develop/dev-best-practices/
- Dockerfile Reference: https://docs.docker.com/engine/reference/builder/

---

## 🎯 Next Steps

- Monitor CI/CD pipeline for successful builds: `docker compose build --parallel`
- Add pre-commit hooks to validate Dockerfile syntax
- Document dependency update procedures
- Set up automated version compatibility checks