Docs/Deployment/Docker

Docker

Add the NxtOne SDK to your container images.

NxtOne is an SDK you install in your application — there is no NxtOne container, sidecar, or daemon to run. The SDK runs inside your service's own process and sends behavioral events straight to the NxtOne platform over HTTPS. Containerizing an instrumented service comes down to three things: install the SDK in your image, pass your API key at run time, and allow outbound HTTPS.

1. What runs where

PieceWhere it runsWhat it does
NxtOne SDKInside your service's process, in your own imageInstruments your code in-process and batches events in memory.
NxtOne platformHosted by NxtOneReceives events from the SDK over HTTPS. Nothing extra runs on your host.

Only services that run your own code need the SDK. Databases, caches, and other off-the-shelf images stay exactly as they are.

Never bake the API key into an image. A key committed into a layer stays in the layer history even after a later ENV overrides it. Pass it at run time with --env-file, Compose env_file, or your orchestrator's secret store.

2. Adding the SDK to your image

Install the SDK as a normal dependency of your application, then build the image the way you already do. The image needs nothing NxtOne-specific beyond that dependency.

Java (Spring Boot)

Add the starter to your build. It attaches the SDK when the application starts, so the Dockerfile needs no -javaagent flag:

xml
<dependency> <groupId>ai.nxtone</groupId> <artifactId>nxtone-agent-spring-boot-starter</artifactId> <version>${nxtone.version}</version> </dependency>
dockerfile
FROM eclipse-temurin:17-jre WORKDIR /app COPY target/app.jar app.jar ENTRYPOINT ["java", "-jar", "/app/app.jar"]

Outside Spring Boot, call Nxtone.attach() as the first line of main(). In a shaded uber-JAR, also set NXTONE_AGENT_JAR to the path of the SDK JAR.

Python (FastAPI / Flask)
dockerfile
FROM python:3.12-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt nxtone COPY . . CMD ["python", "main.py"]

The SDK is activated in your code: decorate the function that starts your server (for FastAPI, the one that calls uvicorn.run) with @nxtone.NxtOneAgent, and run that file. See Python (FastAPI). Requires Python 3.10+.

Node.js (TypeScript / NestJS)
dockerfile
FROM node:20-slim WORKDIR /app COPY package*.json ./ RUN npm ci --omit=dev # @nxtone/agent is a regular dependency COPY dist ./dist CMD ["node", "--import", "@nxtone/agent/register", "dist/main.js"]

--import @nxtone/agent/register loads the SDK before your app. Alternatively, call await nxtone.init() at the top of your entry file and start Node normally. Requires Node.js 20.6+.

Multi-stage builds work unchanged — the SDK only has to be present in the final stage, as part of your application's runtime dependencies.

3. docker-compose.yml

There is no NxtOne service to add. Each instrumented service gets the API key and its own NXTONE_PROJECT_ID, which is what lets NxtOne stitch a single request into a cross-service execution flow:

yaml
services: api-gateway: build: ./gateway ports: - "8080:8080" environment: NXTONE_API_KEY: ${NXTONE_API_KEY} NXTONE_PROJECT_ID: api-gateway depends_on: - payment-service payment-service: build: ./payments environment: NXTONE_API_KEY: ${NXTONE_API_KEY} NXTONE_PROJECT_ID: payment-service postgres: image: postgres:16 # not instrumented — no SDK needed environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}

Compose reads NXTONE_API_KEY from a .env file next to docker-compose.yml, so the value never enters the YAML or the image.

4. Environment variables

VariableRequiredDescription
NXTONE_API_KEYYesAuthenticates the SDK with the platform. Without it the SDK does nothing and your service runs unobserved — it never fails your app.
NXTONE_PROJECT_IDRecommendedGroups execution flows in the UI. Set it explicitly per service — the fallback is not service-specific, so a stack can collapse into a single project.
NXTONE_EXCLUDENoPackages or paths to leave uninstrumented. See Filtering.

See Environment Variables and Filtering for the full reference.

5. Read-only root filesystems

This only matters if your containers run with a read-only root filesystem. The Node.js SDK writes nothing to disk. The Java SDK copies its JAR into the JVM's temp directory (/tmp by default) at startup — if it can't, it logs nxtone: agent attach failed and the service runs uninstrumented. The Python SDK creates a nxtone/ directory under the system temp directory at startup, and writes batches there only when its in-memory queue is full or a send fails. For Java and Python services, mount a tmpfs at /tmp:

yaml
payment-service: read_only: true tmpfs: - /tmp

6. Graceful shutdown

The SDK batches events in memory and flushes them when your process exits. A container killed before that flush loses its last events, so:

  • Use the exec form of CMD/ENTRYPOINT (a JSON array) so your app is PID 1 and receives SIGTERM directly.
  • On Node.js, start your app with node as shown above rather than npx nxtone run — the launcher does not forward SIGTERM to your app.
  • Keep the stop timeout longer than the SDK's flush: Java and Node.js flush for up to 5 seconds, within Docker's 10-second default. The Python SDK can wait up to 60 seconds (NXTONE_SHUTDOWN_TIMEOUT) — set stop_grace_period to match, or lower the timeout.

7. Resource limits

Because the SDK runs inside your process, its overhead counts against your service's own container limits — memory for the event queue, CPU for serialization. Limits sized tightly against an uninstrumented service are the usual cause of post-rollout OOM kills.

There is no universal number. Overhead depends on request volume, payload size, and how aggressively you exclude code paths. Roll out to one host, watch docker stats under representative load, and size from what you observe. Trimming noisy packages with exclusions is usually more effective than raising limits.

8. Verifying the connection

The SDK logs to stderr, so its startup lines appear in your service's container logs:

bash
docker compose logs payment-service | grep -i nxtone
RuntimeWhat to look for
Javanxtone: agent attached, then nxtone: application ready
Node.jsNXTONE_SESSION_ID=…
AnyA hint that the API key is missing means the SDK is running as a no-op — check the environment the container actually received.

If nothing appears, work through Troubleshooting.

9. Network egress

The SDK only makes outbound connections; it opens no ports. In locked-down environments, allow HTTPS (443) from your service containers to the NxtOne API (api.nxtone.ai and www.api.nxtone.ai) and to Amazon S3, which the SDK uses for large payloads.