TheEdict commited on
Commit
9a03317
Β·
verified Β·
1 Parent(s): f971a33

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +86 -82
Dockerfile CHANGED
@@ -1,108 +1,112 @@
1
- # Marimo Zero - Hugging Face Spaces Dockerfile
2
- # Optimized for HF Spaces deployment
3
 
4
- FROM python:3.11-slim
5
 
6
- # 1. System Dependencies
7
- RUN apt-get update && \
8
- DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
9
- curl git bash jq procps net-tools nodejs npm ca-certificates nginx \
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # 2. Install Python Dependencies
13
- RUN pip install --no-cache-dir \
14
- marimo \
15
- huggingface_hub \
16
- tomli \
17
- tomli-w \
18
- fastapi \
19
- uvicorn \
20
- requests
21
-
22
- # 3. Install ZeroClaw (Agent Zero)
23
- RUN curl -fsSL "https://github.com/zeroclaw-labs/zeroclaw/releases/latest/download/zeroclaw-x86_64-unknown-linux-gnu.tar.gz" \
24
- -o zeroclaw.tar.gz && \
25
- tar -xzf zeroclaw.tar.gz && \
26
- mv zeroclaw /usr/local/bin/zeroclaw && \
27
- chmod +x /usr/local/bin/zeroclaw && \
28
- rm zeroclaw.tar.gz
29
-
30
- # 4. Install OmniRoute
31
  RUN npm install -g omniroute
32
 
33
- # 5. Setup Workspace
34
  WORKDIR /app
35
- RUN mkdir -p /app/workspace /app/.zeroclaw /app/.omniroute /var/log/marimo-zero && \
36
- chmod -R 777 /app/workspace /app/.zeroclaw /app/.omniroute /var/log/marimo-zero
37
-
38
- # 6. Copy Config Files
39
- COPY config.toml /app/.zeroclaw/config.toml
40
- COPY omniroute-accounts.json /app/.omniroute/accounts.json
41
-
42
- # 7. Copy Marimo Notebook
43
- COPY marimo_sandbox.py /app/marimo_sandbox.py
44
 
45
- # 8. Copy Static UI
46
- RUN mkdir -p /app/static
47
- COPY static/index.html /app/static/index.html
48
- COPY nginx.conf /etc/nginx/nginx.conf
49
 
50
- # 9. Copy Proxy Server
51
- COPY proxy_server.py /app/proxy_server.py
52
-
53
- # 10. Create Entrypoint Script Inline (avoids file copy issues)
54
- RUN cat > /app/entrypoint.sh << 'ENTRYPOINT_EOF'
55
  #!/bin/bash
56
  set -e
57
- echo "Starting Marimo Zero for Hugging Face Spaces..."
 
 
 
58
  if [ -n "$API_KEYS_JSON" ]; then
59
- echo "Parsing API keys from JSON..."
60
  export OPENAI_API_KEY=$(echo $API_KEYS_JSON | jq -r '.openai // empty')
61
  export ANTHROPIC_API_KEY=$(echo $API_KEYS_JSON | jq -r '.anthropic // empty')
62
- export NVIDIA_API_KEY=$(echo $API_KEYS_JSON | jq -r '.nvidia // empty')
63
- export GROQ_API_KEY=$(echo $API_KEYS_JSON | jq -r '.groq // empty')
64
- export GOOGLE_API_KEY=$(echo $API_KEYS_JSON | jq -r '.google // empty')
65
- echo "API keys loaded from API_KEYS_JSON"
66
- else
67
- echo "WARNING: API_KEYS_JSON not set!"
68
  fi
69
- echo "Starting OmniRoute on port $OMNIROUTE_PORT..."
70
- cat > /app/.omniroute/accounts.json << 'ACCOUNTS_EOF'
71
- {
72
- "accounts": [
73
- {"name": "openai", "provider": "openai", "api_key": "${OPENAI_API_KEY:-dummy}", "default": true}
74
- ]
75
- }
76
- ACCOUNTS_EOF
77
- omniroute start --port $OMNIROUTE_PORT --accounts /app/.omniroute/accounts.json &
78
- sleep 3
79
- echo "Starting Agent Zero on port 80..."
80
- zeroclaw gateway --port 80 --config /app/.zeroclaw/config.toml &
81
- sleep 5
82
- echo "Starting Marimo on port $MARIMO_PORT..."
83
- marimo run /app/marimo_sandbox.py --host 127.0.0.1 --port $MARIMO_PORT --headless &
84
- sleep 3
85
- echo "Starting proxy server on port 7860..."
86
- python3 /app/proxy_server.py &
87
  sleep 2
88
- echo "Marimo Zero Ready!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  wait
90
- ENTRYPOINT_EOF
91
 
92
- RUN chmod +x /app/entrypoint.sh
93
 
94
- # 11. HF Spaces Environment
95
- ENV PORT=7860
96
- ENV MARIMO_PORT=8080
97
- ENV OMNIROUTE_PORT=20128
98
- ENV WORKSPACE=/app/workspace
99
- ENV HOME=/app
100
  ENV HF_SPACE=true
 
101
 
102
- # 12. Expose single port
103
  EXPOSE 7860
104
 
105
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
106
  CMD curl -f http://localhost:7860/health || exit 1
107
 
108
- ENTRYPOINT ["/app/entrypoint.sh"]
 
1
+ # Marimo Zero - Agent Zero + Marimo + OmniRoute
2
+ # Clean minimal setup
3
 
4
+ FROM agent0ai/agent-zero:latest
5
 
6
+ USER root
7
+
8
+ # 1. Install dependencies
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ curl jq python3-pip \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ RUN pip install --no-cache-dir marimo fastapi uvicorn requests
14
+
15
+ # 2. Install OmniRoute
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  RUN npm install -g omniroute
17
 
18
+ # 3. Setup directories
19
  WORKDIR /app
20
+ RUN mkdir -p /app/marimo /app/workspace /app/.omniroute && chmod -R 777 /app
 
 
 
 
 
 
 
 
21
 
22
+ # 4. Copy Marimo notebook
23
+ COPY marimo_sandbox.py /app/marimo/marimo_sandbox.py
 
 
24
 
25
+ # 5. Create startup script
26
+ RUN cat > /app/start.sh << 'EOF'
 
 
 
27
  #!/bin/bash
28
  set -e
29
+
30
+ echo "πŸš€ Starting Marimo Zero..."
31
+
32
+ # Parse API_KEYS_JSON
33
  if [ -n "$API_KEYS_JSON" ]; then
34
+ echo "πŸ“ Loading API keys..."
35
  export OPENAI_API_KEY=$(echo $API_KEYS_JSON | jq -r '.openai // empty')
36
  export ANTHROPIC_API_KEY=$(echo $API_KEYS_JSON | jq -r '.anthropic // empty')
 
 
 
 
 
 
37
  fi
38
+
39
+ # Start OmniRoute
40
+ echo "πŸ“‘ Starting OmniRoute..."
41
+ cat > /app/.omniroute/accounts.json << ACCOUNTS
42
+ {"accounts": [{"name": "openai", "provider": "openai", "api_key": "${OPENAI_API_KEY:-dummy}", "default": true}]}
43
+ ACCOUNTS
44
+ omniroute start --port 20128 --accounts /app/.omniroute/accounts.json &
 
 
 
 
 
 
 
 
 
 
 
45
  sleep 2
46
+
47
+ # Start Marimo
48
+ echo "πŸ““ Starting Marimo..."
49
+ marimo run /app/marimo/marimo_sandbox.py --host 0.0.0.0 --port 8081 --headless &
50
+ sleep 3
51
+
52
+ # Start proxy (Agent Zero on 80, Marimo on 8081, all on 7860)
53
+ echo "πŸ”€ Starting proxy..."
54
+ python3 << 'PROXY'
55
+ from fastapi import FastAPI, Request
56
+ from fastapi.responses import StreamingResponse
57
+ import httpx
58
+
59
+ app = FastAPI()
60
+ client = httpx.AsyncClient(timeout=120.0)
61
+
62
+ @app.get("/health")
63
+ async def health():
64
+ return {"status": "healthy"}
65
+
66
+ @app.get("/marimo")
67
+ async def marimo_redir():
68
+ from fastapi.responses import RedirectResponse
69
+ return RedirectResponse(url="/marimo/")
70
+
71
+ @app.api_route("/marimo/{path:path}", methods=["GET","POST","PUT","DELETE","PATCH"])
72
+ async def marimo_proxy(request: Request, path: str):
73
+ url = f"http://localhost:8081/{path}"
74
+ h = dict(request.headers)
75
+ h.pop("host", None)
76
+ b = await request.body() if request.method in ["POST","PUT","PATCH"] else None
77
+ r = await client.request(request.method, url, headers=h, content=b)
78
+ return StreamingResponse(r.aiter_bytes(), status_code=r.status_code, headers=dict(r.headers))
79
+
80
+ @app.api_route("/{path:path}", methods=["GET","POST","PUT","DELETE","PATCH"])
81
+ async def az_proxy(request: Request, path: str):
82
+ url = f"http://localhost:80/{path}" if path else "http://localhost:80"
83
+ h = dict(request.headers)
84
+ h.pop("host", None)
85
+ b = await request.body() if request.method in ["POST","PUT","PATCH"] else None
86
+ r = await client.request(request.method, url, headers=h, content=b)
87
+ return StreamingResponse(r.aiter_bytes(), status_code=r.status_code, headers=dict(r.headers))
88
+
89
+ if __name__ == "__main__":
90
+ import uvicorn
91
+ uvicorn.run(app, host="0.0.0.0", port=7860)
92
+ PROXY
93
+
94
+ echo "βœ… Ready!"
95
+ echo " Agent Zero: http://localhost:7860"
96
+ echo " Marimo: http://localhost:7860/marimo/"
97
  wait
98
+ EOF
99
 
100
+ RUN chmod +x /app/start.sh
101
 
102
+ # 6. Environment
 
 
 
 
 
103
  ENV HF_SPACE=true
104
+ ENV WORKSPACE=/app/workspace
105
 
106
+ # 7. Port
107
  EXPOSE 7860
108
 
109
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
110
  CMD curl -f http://localhost:7860/health || exit 1
111
 
112
+ ENTRYPOINT ["/app/start.sh"]