datagrok-tools 5.1.8 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,236 @@
1
+ # Packages Dev — lightweight JS/TS package development environment
2
+ # Usage: docker compose up -d
3
+ #
4
+ # All images are pre-built on Docker Hub. No local build step needed.
5
+ # The Dockerfile.pkg_dev in this directory is the build recipe for the
6
+ # datagrok/tools-dev image — used by CI, not by end users.
7
+ #
8
+ # On Windows, use `grok claude` instead — it handles path conversion
9
+ # and Docker socket mapping automatically.
10
+
11
+ services:
12
+ postgres:
13
+ image: pgvector/pgvector:pg17
14
+ command: postgres -c 'max_connections=1000'
15
+ environment:
16
+ POSTGRES_USER: postgres
17
+ POSTGRES_PASSWORD: postgres
18
+ volumes:
19
+ - pgdata:/var/lib/postgresql/data
20
+ shm_size: 2gb
21
+ healthcheck:
22
+ test: ["CMD-SHELL", "pg_isready -U postgres"]
23
+ interval: 5s
24
+ retries: 10
25
+ networks:
26
+ dg:
27
+ aliases:
28
+ - database
29
+ - postgres
30
+ restart: unless-stopped
31
+
32
+ rabbitmq:
33
+ image: rabbitmq:4.0.5-management
34
+ platform: linux/amd64
35
+ environment:
36
+ RABBITMQ_DEFAULT_USER: guest
37
+ RABBITMQ_DEFAULT_PASS: guest
38
+ networks:
39
+ dg:
40
+ aliases:
41
+ - rabbitmq
42
+ restart: unless-stopped
43
+
44
+ grok_pipe:
45
+ image: datagrok/grok_pipe:${DG_VERSION:-latest}
46
+ platform: linux/amd64
47
+ environment:
48
+ API_KEY: test-key
49
+ networks:
50
+ dg:
51
+ aliases:
52
+ - grok_pipe
53
+ restart: unless-stopped
54
+
55
+ datagrok:
56
+ image: datagrok/datagrok:${DG_VERSION:-latest}
57
+ depends_on:
58
+ postgres:
59
+ condition: service_healthy
60
+ rabbitmq:
61
+ condition: service_started
62
+ environment:
63
+ GROK_PARAMETERS: |
64
+ {
65
+ "dbServer": "database",
66
+ "db": "datagrok",
67
+ "dbLogin": "dg",
68
+ "dbPassword": "dg",
69
+ "dbAdminLogin": "postgres",
70
+ "dbAdminPassword": "postgres",
71
+ "adminPassword": "admin",
72
+ "adminDevKey": "admin",
73
+ "webRoot": "http://datagrok:8080",
74
+ "apiRoot": "http://datagrok:8080/api",
75
+ "deployDemo": true,
76
+ "deployTestDemo": false
77
+ }
78
+ ports:
79
+ - "${DG_PORT:-0}:8080"
80
+ volumes:
81
+ - datagrok_data:/home/grok/data
82
+ - datagrok_cfg:/home/grok/cfg
83
+ networks:
84
+ dg:
85
+ aliases:
86
+ - datagrok
87
+ restart: on-failure
88
+
89
+ # ── Optional services (use --profile to enable) ──────────────
90
+
91
+ grok_connect:
92
+ image: datagrok/grok_connect:${DG_VERSION:-latest}
93
+ platform: linux/amd64
94
+ environment:
95
+ GROK_CONNECT_PORT: 1234
96
+ networks:
97
+ dg:
98
+ aliases:
99
+ - grok_connect
100
+ restart: unless-stopped
101
+ profiles: ["full"]
102
+
103
+ grok_spawner:
104
+ image: datagrok/grok_spawner:${DG_VERSION:-latest}
105
+ platform: linux/amd64
106
+ user: root
107
+ environment:
108
+ X_API_KEY: test-x-api-key
109
+ GROK_SPAWNER_ENVIRONMENT: ${COMPOSE_PROJECT_NAME:-dg-pkg}
110
+ GROK_SPAWNER_CORE_MODE: "false"
111
+ GROK_SPAWNER_FORCE_DOCKER_TYPE_HOST: "true"
112
+ volumes:
113
+ - /var/run/docker.sock:/var/run/docker.sock
114
+ networks:
115
+ dg:
116
+ aliases:
117
+ - grok_spawner
118
+ restart: unless-stopped
119
+ profiles: ["full"]
120
+
121
+ jupyter_kernel_gateway:
122
+ image: datagrok/jupyter_kernel_gateway:${DG_VERSION:-latest}
123
+ platform: linux/amd64
124
+ depends_on:
125
+ rabbitmq:
126
+ condition: service_started
127
+ environment:
128
+ GROK_PARAMETERS: |
129
+ {
130
+ "queueSettings": {
131
+ "useQueue": true,
132
+ "amqpHost": "rabbitmq",
133
+ "amqpUser": "guest",
134
+ "amqpPassword": "guest",
135
+ "amqpPort": 5672,
136
+ "pipeHost": "grok_pipe",
137
+ "pipePort": 3000,
138
+ "pipeKey": "test-key",
139
+ "maxConcurrentCalls": 16
140
+ }
141
+ }
142
+ networks:
143
+ dg:
144
+ aliases:
145
+ - jupyter_kernel_gateway
146
+ restart: unless-stopped
147
+ profiles: ["scripting", "full"]
148
+
149
+ world:
150
+ image: datagrok/demo_db_postgres:12-1.1.0
151
+ environment:
152
+ POSTGRES_DB: world
153
+ POSTGRES_USER: postgres
154
+ POSTGRES_PASSWORD: postgres
155
+ volumes:
156
+ - demo_world:/var/lib/postgresql/data
157
+ networks:
158
+ dg:
159
+ aliases:
160
+ - world
161
+ restart: on-failure
162
+ profiles: ["demo", "full"]
163
+
164
+ test_db:
165
+ image: datagrok/demo_db_postgres:12-1.1.0
166
+ environment:
167
+ POSTGRES_DB: test
168
+ POSTGRES_USER: postgres
169
+ POSTGRES_PASSWORD: postgres
170
+ volumes:
171
+ - demo_test:/var/lib/postgresql/data
172
+ networks:
173
+ dg:
174
+ aliases:
175
+ - test_db
176
+ restart: on-failure
177
+ profiles: ["demo", "full"]
178
+
179
+ northwind:
180
+ image: datagrok/demo_db_postgres:12-1.1.0
181
+ environment:
182
+ POSTGRES_DB: northwind
183
+ POSTGRES_USER: postgres
184
+ POSTGRES_PASSWORD: postgres
185
+ volumes:
186
+ - demo_northwind:/var/lib/postgresql/data
187
+ networks:
188
+ dg:
189
+ aliases:
190
+ - northwind
191
+ restart: on-failure
192
+ profiles: ["demo", "full"]
193
+
194
+ # ── Package dev container (pre-built image from Docker Hub) ──
195
+
196
+ tools-dev:
197
+ image: datagrok/tools-dev:${DG_TOOLS_DEV_VERSION:-latest}
198
+ cap_add:
199
+ - SYS_ADMIN
200
+ security_opt:
201
+ - seccomp=unconfined
202
+ volumes:
203
+ - ${WORKTREE_PATH:-.}:/workspace
204
+ - ${HOST_HOME:-${HOME}}/.claude:/home/node/.claude
205
+ - ${HOST_HOME:-${HOME}}/.grok:/home/node/.grok
206
+ - /var/run/docker.sock:/var/run/docker.sock
207
+ - npm_cache:/home/node/.npm
208
+ environment:
209
+ ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
210
+ DG_VERSION: ${DG_VERSION:-latest}
211
+ DG_PUBLIC_REPO: ${DG_PUBLIC_REPO:-https://github.com/datagrok-ai/public.git}
212
+ DG_PUBLIC_BRANCH: ${DG_PUBLIC_BRANCH:-}
213
+ JIRA_URL: ${JIRA_URL:-https://reddata.atlassian.net}
214
+ JIRA_USERNAME: ${JIRA_USERNAME}
215
+ JIRA_TOKEN: ${JIRA_TOKEN}
216
+ GITHUB_TOKEN: ${GITHUB_TOKEN}
217
+ networks:
218
+ dg:
219
+ aliases:
220
+ - tools-dev
221
+ stdin_open: true
222
+ tty: true
223
+ restart: unless-stopped
224
+
225
+ volumes:
226
+ pgdata:
227
+ datagrok_data:
228
+ datagrok_cfg:
229
+ demo_world:
230
+ demo_test:
231
+ demo_northwind:
232
+ npm_cache:
233
+
234
+ networks:
235
+ dg:
236
+ name: dg-pkg-${TASK_KEY:-default}-net
@@ -0,0 +1,93 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Resolve the actual version when DG_VERSION is "latest" — needed for git branch matching.
5
+ resolve_version() {
6
+ local ver="${1:-latest}"
7
+ if [ "$ver" = "latest" ]; then
8
+ echo "[tools-dev] Resolving latest Datagrok version from Docker Hub..." >&2
9
+ local resolved
10
+ resolved=$(curl -sf "https://hub.docker.com/v2/repositories/datagrok/datagrok/tags?page_size=100&ordering=-name" \
11
+ | node -e "
12
+ const data = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));
13
+ const tags = (data.results||[]).map(t=>t.name).filter(n=>/^\d+\.\d+\.\d+$/.test(n));
14
+ tags.sort((a,b)=>{
15
+ const pa=a.split('.').map(Number), pb=b.split('.').map(Number);
16
+ return pb[0]-pa[0]||pb[1]-pa[1]||pb[2]-pa[2];
17
+ });
18
+ if(tags[0]) process.stdout.write(tags[0]);
19
+ " 2>/dev/null) || true
20
+ if [ -n "$resolved" ]; then
21
+ echo "[tools-dev] Resolved latest version: $resolved" >&2
22
+ echo "$resolved"
23
+ else
24
+ echo "[tools-dev] Could not resolve latest version, falling back to master" >&2
25
+ echo "master"
26
+ fi
27
+ else
28
+ echo "$ver"
29
+ fi
30
+ }
31
+
32
+ PUBLIC_DIR="/workspace/public"
33
+ # Detect if /workspace/repo IS the public repo (has js-api/ at root)
34
+ if [ -d "/workspace/repo/js-api" ]; then
35
+ echo "[tools-dev] Public repo detected at /workspace/repo — skipping clone."
36
+ elif [ -d "/workspace/repo/public/js-api" ]; then
37
+ echo "[tools-dev] Monorepo detected — public repo at /workspace/repo/public."
38
+ elif [ -d "$PUBLIC_DIR/js-api" ]; then
39
+ echo "[tools-dev] Public repo already at $PUBLIC_DIR."
40
+ else
41
+ REPO="${DG_PUBLIC_REPO:-https://github.com/datagrok-ai/public.git}"
42
+ # Resolve branch: explicit DG_PUBLIC_BRANCH > resolved DG_VERSION > master
43
+ if [ -n "$DG_PUBLIC_BRANCH" ]; then
44
+ BRANCH="$DG_PUBLIC_BRANCH"
45
+ else
46
+ BRANCH=$(resolve_version "${DG_VERSION:-latest}")
47
+ fi
48
+ echo "[tools-dev] Cloning public repo ($BRANCH) into $PUBLIC_DIR..."
49
+ git clone --depth 1 --branch "$BRANCH" "$REPO" "$PUBLIC_DIR" 2>/dev/null \
50
+ || { echo "[tools-dev] Branch '$BRANCH' not found, falling back to master."
51
+ git clone --depth 1 --branch master "$REPO" "$PUBLIC_DIR"; }
52
+ echo "[tools-dev] Public repo ready at $PUBLIC_DIR (branch: $(git -C "$PUBLIC_DIR" branch --show-current))."
53
+ fi
54
+
55
+ # ── Mount workspace inside public repo for non-public workspaces ──
56
+ # When TASK_KEY is set and workspace is not the public repo, link it into packages/
57
+ # so Claude Code walks up to find all public repo context (CLAUDE.md, .claude/, js-api/, etc.)
58
+ if [ -d "/workspace/repo/js-api" ]; then
59
+ echo "[tools-dev] Public repo IS the workspace — no linking needed."
60
+ elif [ -d "/workspace/repo/public/js-api" ]; then
61
+ echo "[tools-dev] Monorepo detected — public context at /workspace/repo/public/."
62
+ elif [ -d "$PUBLIC_DIR/js-api" ]; then
63
+ # Cloned public repo — link workspace into packages/ and expose context at /workspace/
64
+ if [ -n "$TASK_KEY" ]; then
65
+ mkdir -p "$PUBLIC_DIR/packages" 2>/dev/null || true
66
+ [ ! -e "$PUBLIC_DIR/packages/$TASK_KEY" ] && ln -s /workspace/repo "$PUBLIC_DIR/packages/$TASK_KEY"
67
+ echo "[tools-dev] Workspace linked at $PUBLIC_DIR/packages/$TASK_KEY"
68
+ fi
69
+ [ ! -e /workspace/.claude ] && ln -s public/.claude /workspace/.claude
70
+ [ ! -e /workspace/CLAUDE.md ] && ln -s public/CLAUDE.md /workspace/CLAUDE.md
71
+ echo "[tools-dev] Linked public repo context at /workspace/"
72
+ fi
73
+
74
+ # Auto-configure grok CLI to point to the local Datagrok instance.
75
+ # Only creates the config if it doesn't already exist (preserves host config).
76
+ GROK_DIR="/home/node/.grok"
77
+ GROK_CFG="$GROK_DIR/config.yaml"
78
+ if [ ! -f "$GROK_CFG" ] || [ ! -s "$GROK_CFG" ]; then
79
+ mkdir -p "$GROK_DIR" 2>/dev/null || true
80
+ cat > "$GROK_CFG" <<'YAML' 2>/dev/null || true
81
+ default: local
82
+ servers:
83
+ local:
84
+ url: http://datagrok:8080/api
85
+ key: admin
86
+ YAML
87
+ [ -s "$GROK_CFG" ] && echo "[tools-dev] Created grok config at $GROK_CFG"
88
+ elif ! grep -q "datagrok:8080" "$GROK_CFG" 2>/dev/null; then
89
+ echo "[tools-dev] Note: existing grok config found. Add 'local' server with:"
90
+ echo " grok config add --alias local --server http://datagrok:8080/api --key admin --default"
91
+ fi
92
+
93
+ exec "$@"