Skip to content

Commit c395daf

Browse files
committed
-
1 parent b923773 commit c395daf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+921
-298
lines changed

config/MAR-INF/MANIFEST.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"createdOn": "09/05/2025 14:18:23",
3+
"runtime": "python",
4+
"model": {
5+
"modelName": "monai-breast-density-classification",
6+
"serializedFile": "model.pt",
7+
"handler": "inference_handler.py",
8+
"modelVersion": "1.0",
9+
"requirementsFile": "requirements.txt",
10+
"configFile": "model-config.yaml"
11+
},
12+
"archiverVersion": "0.12.0"
13+
}

config/__init__.py

Whitespace-only changes.

config/config.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ install_py_dep_per_model=true
1515
async_logging=false
1616
model_store=/mnt/models/model-store
1717
enable_token_auth=false
18-
model_snapshot={"name":"startup.cfg","modelCount":1,"models":{"monai-breast-density-classification":{"1.0":{"defaultVersion":true,"marName":"monai-breast-density-classification.mar","minWorkers":1,"maxWorkers":1,"batchSize":16,"maxBatchDelay":10,"responseTimeout":3600}}}}
18+
disable_token_auth=true
19+
model_snapshot={"name":"startup.cfg","modelCount":1,"models":{"breast-density":{"1.0":{"defaultVersion":true,"marName":"monai-breast-density-classification_model-store_monai-breast-density-classification.mar","minWorkers":1,"maxWorkers":1,"batchSize":16,"maxBatchDelay":10,"responseTimeout":3600}}}}
20+
21+
# model_snapshot={"name":"startup.cfg","modelCount":1,"models":{"monai-breast-density-classification":{"1.0":{"defaultVersion":true,"marName":"monai-breast-density-classification.mar","minWorkers":1,"maxWorkers":1,"batchSize":16,"maxBatchDelay":10,"responseTimeout":3600}}}}

config/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
monai_breast_density_classification-0.1.tar.gz

dockerize/Caddyfile

Lines changed: 76 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,78 @@
1-
# Caddyfile for MONAI Breast Density Classification
2-
# Simple reverse proxy to auth-gateway service
3-
4-
# Main site configuration
5-
:23434 {
6-
# TLS configuration using provided certificates
7-
tls /etc/ssl/certs/fullchain.pem /etc/ssl/private/privkey.pem
8-
9-
# Reverse proxy all requests to auth-gateway
10-
reverse_proxy auth-gateway:8090 {
11-
# Health check for upstream
12-
health_uri /health
13-
health_interval 30s
14-
health_timeout 10s
15-
16-
# Forward original client information
17-
header_up Host {host}
18-
header_up X-Real-IP {remote_host}
19-
header_up X-Forwarded-For {remote_host}
20-
header_up X-Forwarded-Proto {scheme}
21-
header_up X-Forwarded-Port {server_port}
22-
}
23-
24-
# Request/response logging for debugging (optional)
25-
log {
26-
output stdout
27-
format console
28-
level INFO
29-
}
30-
31-
# Security headers
32-
header {
33-
# Remove server identification
34-
-Server
35-
# Basic security headers
36-
X-Content-Type-Options nosniff
37-
X-Frame-Options DENY
38-
X-XSS-Protection "1; mode=block"
39-
Referrer-Policy strict-origin-when-cross-origin
40-
}
41-
42-
# Handle specific endpoints with better error pages
43-
handle_errors {
44-
@502 expression {http.error.status_code} == 502
45-
@503 expression {http.error.status_code} == 503
46-
@504 expression {http.error.status_code} == 504
47-
48-
respond @502 "Service temporarily unavailable - auth-gateway not ready" 502
49-
respond @503 "Service temporarily unavailable - please try again" 503
50-
respond @504 "Service timeout - request took too long" 504
51-
}
1+
{
2+
debug
3+
order claive_reverse_proxy first
4+
log {
5+
output stdout
6+
format console
7+
level DEBUG
8+
}
529
}
5310

54-
# Optional: Redirect HTTP to HTTPS if needed
55-
# :80 {
56-
# redir https://{host}:23434{uri} permanent
57-
# }
11+
# HTTP to HTTPS redirect (eliminates TLS handshake errors)
12+
fetchai.scrtlabs.com:80 {
13+
redir https://fetchai.scrtlabs.com:23434{uri} permanent
14+
}
15+
16+
# Main HTTPS site configuration for fetchai.scrtlabs.com
17+
fetchai.scrtlabs.com:23434 {
18+
# TLS configuration using provided certificates
19+
tls /etc/ssl/certs/fullchain.pem /etc/ssl/private/privkey.pem
20+
21+
@cors_preflight method OPTIONS
22+
handle @cors_preflight {
23+
header {
24+
Access-Control-Allow-Origin "{header.origin}"
25+
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
26+
Access-Control-Allow-Headers "Content-Type, Authorization, Referrer-Policy, priority, sec-ch-ua, sec-ch-ua-mobile, sec-ch-ua-platform"
27+
Access-Control-Allow-Credentials "true"
28+
Vary Origin
29+
Access-Control-Max-Age "3600"
30+
}
31+
respond "" 204
32+
}
33+
34+
handle {
35+
header {
36+
Access-Control-Allow-Origin "{header.origin}"
37+
Access-Control-Allow-Headers "Content-Type, Authorization, Referrer-Policy, priority, sec-ch-ua, sec-ch-ua-mobile, sec-ch-ua-platform"
38+
Access-Control-Allow-Credentials "true"
39+
Vary Origin
40+
}
41+
claive_reverse_proxy {
42+
API_MASTER_KEY bWFzdGVyQHNjcnRsYWJzLmNvbTpTZWNyZXROZXR3b3JrTWFzdGVyS2V5X18yMDI1
43+
}
44+
reverse_proxy auth-gateway:8090 {
45+
# Health check for upstream
46+
health_uri /health
47+
health_interval 30s
48+
health_timeout 10s
49+
50+
# Forward original client information
51+
header_up Host {host}
52+
header_up X-Real-IP {remote_host}
53+
header_up X-Forwarded-Port {server_port}
54+
}
55+
}
56+
57+
# Security headers
58+
header {
59+
# Remove server identification
60+
-Server
61+
# Basic security headers
62+
X-Content-Type-Options nosniff
63+
X-Frame-Options DENY
64+
X-XSS-Protection "1; mode=block"
65+
Referrer-Policy strict-origin-when-cross-origin
66+
}
67+
68+
# Handle specific endpoints with better error pages
69+
handle_errors {
70+
@502 expression {http.error.status_code} == 502
71+
@503 expression {http.error.status_code} == 503
72+
@504 expression {http.error.status_code} == 504
73+
74+
respond @502 "Service temporarily unavailable - auth-gateway not ready" 502
75+
respond @503 "Service temporarily unavailable - please try again" 503
76+
respond @504 "Service timeout - request took too long" 504
77+
}
78+
}

dockerize/architecture.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
```mermaid
2+
graph TB
3+
%% External Services
4+
OpenAI[OpenAI API]
5+
Perplexity[Perplexity API]
6+
GCS[Google Cloud Storage]
7+
Client[External Client]
8+
9+
%% Docker Environment
10+
subgraph "Docker Network (monai-network)"
11+
%% Caddy Reverse Proxy
12+
Caddy[Caddy Reverse Proxy<br/>Port 23434<br/>HTTPS Entry Point]
13+
14+
%% Auth Gateway
15+
AuthGW[Auth Gateway<br/>FastAPI Service<br/>Port 8090]
16+
17+
%% TorchServe
18+
TorchServe[TorchServe<br/>ML Model Serving<br/>Port 8085<br/>GPU Enabled]
19+
20+
%% Ollama Services
21+
Ollama[Ollama Service<br/>LLM Runtime<br/>Port 11434<br/>GPU Enabled]
22+
OllamaInit[Ollama Init<br/>Model Loader<br/>One-time execution]
23+
end
24+
25+
%% Shared Storage
26+
subgraph "Shared Volumes"
27+
Tokens[torchserve-tokens]
28+
Workspace[shared-workspace]
29+
Models[Host Model Storage<br/>/mnt/secure/.ollama]
30+
end
31+
32+
%% External Client Communication
33+
Client -->|HTTPS:23434| Caddy
34+
35+
%% Internal Container Communication
36+
Caddy -->|HTTP| AuthGW
37+
AuthGW -->|HTTP:8085| TorchServe
38+
TorchServe -->|HTTP:11434<br/>Ollama Python Client| Ollama
39+
40+
%% Dependencies
41+
OllamaInit -.->|depends_on<br/>pulls model| Ollama
42+
AuthGW -.->|depends_on| TorchServe
43+
TorchServe -.->|depends_on| Ollama
44+
Caddy -.->|depends_on| AuthGW
45+
46+
%% External Service Communications (from TorchServe)
47+
TorchServe -->|API Calls| OpenAI
48+
TorchServe -->|API Calls| Perplexity
49+
TorchServe -->|Upload Medical Reports| GCS
50+
51+
%% Volume Mounts
52+
TorchServe -.->|shares tokens| Tokens
53+
TorchServe -.->|shares workspace| Workspace
54+
AuthGW -.->|reads tokens| Tokens
55+
AuthGW -.->|shares workspace| Workspace
56+
Ollama -.->|model storage| Models
57+
OllamaInit -.->|model storage| Models
58+
59+
%% Styling
60+
classDef container fill:#e1f5fe,stroke:#01579b,stroke-width:2px
61+
classDef proxy fill:#f1f8e9,stroke:#33691e,stroke-width:2px
62+
classDef external fill:#fff3e0,stroke:#e65100,stroke-width:2px
63+
classDef storage fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
64+
classDef init fill:#fce4ec,stroke:#880e4f,stroke-width:2px
65+
classDef client fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
66+
67+
class TorchServe,Ollama,AuthGW container
68+
class Caddy proxy
69+
class OpenAI,Perplexity,GCS external
70+
class Tokens,Workspace,Models storage
71+
class OllamaInit init
72+
class Client client
73+
```

0 commit comments

Comments
 (0)