본문으로 건너뛰기
cccskills
무료GitHub에 공개

create-docker-container

Add a Docker container to a Datagrok package with Dockerfile and config

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Docker
설치 방법 보기

포함된 파일(1)

  • SKILL.md6.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Create Docker Container

Help the user add a Docker container to their Datagrok package so it can be built, deployed, and accessed via the platform.

Usage

/create-docker-container [package-name]

Instructions

Follow these steps to create a Docker container for a Datagrok package:

1. Create the Dockerfile

Create a dockerfiles/ folder inside the package root and add a Dockerfile there.

  • The container MUST expose exactly one port using EXPOSE $PORT (only one EXPOSE is allowed).
  • The application inside the container MUST embed an HTTP server listening on that port.
  • Follow Docker best practices: minimal base images, multi-stage builds, small layers.

Example structure:

packages/MyPackage/
  dockerfiles/
    Dockerfile
    container.json   (optional)
  src/
  package.json

2. Create container.json (optional)

Place container.json in the same directory as the Dockerfile. If omitted, defaults are used.

{
  "cpu": 1.5,
  "gpu": 1,
  "memory": 2048,
  "on_demand": true,
  "shutdown_timeout": 60,
  "storage": 25,
  "env": {
    "CONN": "#{x.Package:Entity}",
    "LOGIN": "login"
  }
}

Configuration properties and defaults:

PropertyTypeDefaultDescription
cpuDouble0.25CPU cores allocated
gpuInteger0GPU devices reserved
memoryInteger512RAM in megabytes
on_demandBooleanfalseStart container only on first request
shutdown_timeoutIntegernullIdle minutes before auto-shutdown
storageInteger21Disk storage in gigabytes
shm_sizeInteger64Shared memory in megabytes
envObjectEnvironment variables passed to the container
imageStringPublished image to run instead of building one
portIntegerPort the container listens on (EXPOSE when built here)

Set image when the image is already published — built by a CI pipeline, kept in another repository, or a stock third-party image. The folder then needs no Dockerfile at all, and grok publish builds and pushes nothing:

{
  "image": "datagrok/jkg_python:bleeding-edge",
  "port": 8888,
  "on_demand": true
}

Set port alongside it — with no Dockerfile there is no EXPOSE to read. A folder holding both a Dockerfile and an image is built from the Dockerfile.

For env values, use #{x.Package:Entity} to pass a JSON-serialized entity from a package namespace. Credentials are only passed for connections within the same package.

3. Implement HTTP request access

Get the container ID and use fetchProxy to call the container's HTTP server:

const containerId = (await grok.dapi.docker.dockerContainers.filter('my-container').first()).id;

const params = {
  method: 'POST',
  headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
  body: JSON.stringify(payload),
};
const response: Response = await grok.dapi.docker.dockerContainers.fetchProxy(containerId, '/endpoint', params);
const result = await response.json();

The params object follows the standard RequestInit interface.

4. Implement WebSocket access (if needed)

const ws: WebSocket = await grok.dapi.docker.dockerContainers.webSocketProxy(container.id, '/ws');
ws.send('Hello');

ws.addEventListener('message', (event: MessageEvent) => {
  console.log(event.data);
});

setTimeout(() => ws.close(), 3000);

Read the calling user's credentials (if needed)

Every proxied HTTP request and WebSocket handshake reaches the container with two headers: X-User-Api-Key (the user's session token) and X-Datagrok-Container-Token (valid 15 minutes, good only for the call below). Trade the second one for the credentials of the user who made the call: the package's credentials with the container's own laid over them, each picked by the user's groups. Set them per group in the package's Credentials... dialog; uncheck Allow client side there to keep them away from the package's browser code.

import os, requests

def caller_credentials(request):
    token = request.headers['X-Datagrok-Container-Token']
    r = requests.get(f"{os.environ['DATAGROK_API_URL']}/docker/credentials",
                     headers={'Authorization': f'Bearer {token}'})
    r.raise_for_status()  # 404: no credentials for this user's groups
    return r.json()       # {'apiKey': '...', ...}

A WebSocket gets one token per connection: fetch the credentials when the socket opens.

5. Build and publish

webpack
grok publish dev

A return code of 0 indicates successful deployment. After publishing, Datagrok queues the image for building automatically.

6. Monitor status

In Datagrok, go to Platform -> Dockers to view containers and images. Status indicators:

  • Green dot: running/ready
  • Red dot: error
  • Blinking grey dot: pending (starting, stopping, or rebuilding)
  • No dot: stopped

Right-click a card to start/stop containers or rebuild images. Check logs via the Property pane.

Behavior

  • Ask the user for the package name and what service the container will run.
  • Create the dockerfiles/ directory, Dockerfile, and optionally container.json.
  • If the user needs HTTP access, generate a TypeScript helper function using fetchProxy.
  • If the user needs WebSocket access, generate a helper using webSocketProxy.
  • Remind the user that only one EXPOSE port is allowed in the Dockerfile.
  • Remind the user that grok-spawner must be running in the same environment.
  • Follow project coding conventions: no excessive comments, prefer for-in loops, catch/else if on new lines.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Add support for a new curve data format in the Curves package converter system

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Create info panels that appear in the context panel based on semantic types

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Add a new single-objective optimization algorithm to the sci-comp library. Use when the user asks to implement a new optimizer (e.g. gradient descent, BFGS, simulated annealing, differential evolution).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Add unit tests to a Datagrok package

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Answer a "how do I …" question about the platform with a Gherkin scenario on @datagrok-libraries/bdd that is filmed into a how-to video (grok-bdd guide), so the answer is demonstrated, sent as a video plus numbered steps, and kept as a regression test; the same scenarios, filmed in help mode, are the GIFs of the help pages

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Translate hand-written Playwright specs (or any existing UI tests) into Gherkin features on @datagrok-libraries/bdd, then prove the features test what they claim by backward-matching them against the originals with independent reviewers, and fix the gaps in the core, the library and the features

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

datagrok-ai의 스킬 모두 보기

이 스킬의 문제 신고