Processor Dockerfile
Docker container configuration for processors
Processor Dockerfile
Processors run as Docker containers. The Dockerfile defines the container environment. The examples below show recommended patterns for Bun/TypeScript processors. Python and .NET have different patterns documented in their respective sections.
Minimal Dockerfile
FROM oven/bun:1.3.8WORKDIR /app# Required: Mark as CyanPrint processorLABEL cyanprint.dev=true# Install dependenciesCOPY package.json .COPY bun.lockb .RUN bun install# Copy processor codeCOPY . .# Run processorCMD ["bun", "run", "index.ts"]
Required Elements
LABEL cyanprint.dev=true
This label identifies the container as a CyanPrint processor. Without it, the processor won't be recognized:
LABEL cyanprint.dev=true
WORKDIR
Set the working directory. The convention is /app:
WORKDIR /app
CMD
The command that runs the processor:
# BunCMD ["bun", "run", "index.ts"]# Node.jsCMD ["node", "index.js"]# PythonCMD ["python", "-u", "main.py"]# .NET (use ENTRYPOINT instead)ENTRYPOINT ["dotnet", "Processor.dll"]
Using Node.js
If you prefer Node.js over Bun:
FROM node:20-alpineWORKDIR /appLABEL cyanprint.dev=true# Install dependenciesCOPY package*.json ./RUN npm ci --only=production# Copy processor codeCOPY . .CMD ["node", "index.js"]
Using Python
Python processors use a different pattern:
FROM python:3.12.12WORKDIR /appLABEL cyanprint.dev=true# Install dependenciesCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt# Copy processor codeCOPY . .CMD ["python", "-u", "main.py"]
Using .NET
.NET processors use multi-stage builds and require explicit port configuration:
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS baseWORKDIR /appFROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS buildARG TARGETARCHWORKDIR /srcCOPY ["Processor.csproj", "./"]RUN dotnet restore -a $TARGETARCH "Processor.csproj"COPY . .WORKDIR "/src/"RUN dotnet build "Processor.csproj" -a $TARGETARCH -c Release -o /app/buildFROM build AS publishRUN dotnet publish "Processor.csproj" -a "$TARGETARCH" -c Release -o /app/publish /p:UseAppHost=falseFROM base AS finalLABEL cyanprint.dev=trueENV ASPNETCORE_URLS=http://+:5551WORKDIR /appCOPY --from=publish /app/publish .ENTRYPOINT ["dotnet", "Processor.dll"]
Multi-Stage Build
For smaller images with compiled code:
# Build stageFROM oven/bun:1.3.8-alpine AS builderWORKDIR /appCOPY package.json .COPY bun.lockb .RUN bun installCOPY . .RUN bun build index.ts --outdir=dist --target=bun# Runtime stageFROM oven/bun:1.3.8-alpineWORKDIR /appLABEL cyanprint.dev=trueCOPY --from=builder /app/dist/index.js ./COPY --from=builder /app/node_modules ./node_modulesCMD ["bun", "run", "index.js"]
Including Additional Files
Configuration Files
COPY config ./configCOPY templates ./templates
Binary Tools
# Install additional toolsRUN apt-get update && apt-get install -y \jq \yq \&& rm -rf /var/lib/apt/lists/*COPY . .
Environment Variables
# Set environment variablesENV NODE_ENV=productionENV LOG_LEVEL=info# Runtime environment (can be overridden)ENV PROCESSOR_DEBUG=false
Best Practices
1. Use Specific Versions
# Good: Specific versionFROM oven/bun:1.3.8# Avoid: Latest (unpredictable)FROM oven/bun:latest
Choose a version that matches your development environment. Current stable versions include 1.3.8 and later.
2. Minimize Layers
# Good: Combined commandsRUN apt-get update && apt-get install -y \curl \jq \&& rm -rf /var/lib/apt/lists/*# Avoid: Multiple layersRUN apt-get updateRUN apt-get install -y curlRUN apt-get install -y jq
3. Use .dockerignore
Create a .dockerignore file:
node_modules.git.gitignore*.mdtests/.env*
4. Copy Lockfile Separately
# Good: Separate COPY commandsCOPY package.json .COPY bun.lockb .RUN bun install# Avoid: Glob pattern (may silently skip lockfile)COPY package.json bun.lockb* ./
Processors should be deterministic. Always include your lockfile to ensure consistent dependency versions across builds.
Port Configuration
Processors communicate over port 5551 by default. The SDKs handle this automatically for Bun and Python:
- Bun/Node.js SDK: Listens on port 5551 automatically
- Python SDK: Listens on port 5551 automatically
- .NET SDK: Requires explicit configuration:
ENV ASPNETCORE_URLS=http://+:5551
Full Example
#syntax=docker/dockerfile:1# Build stageFROM oven/bun:1.3.8-alpine AS builderWORKDIR /app# Install build dependenciesCOPY package.json .COPY bun.lockb .RUN bun install# BuildCOPY tsconfig.json ./COPY src ./srcCOPY index.ts ./RUN bun build index.ts --outdir=dist --target=bun --minify# Runtime stageFROM oven/bun:1.3.8-alpineWORKDIR /app# Required labelLABEL cyanprint.dev=trueLABEL org.opencontainers.image.source=https://github.com/org/my-processorLABEL org.opencontainers.image.description="My custom processor"# Copy built filesCOPY --from=builder /app/dist/index.js ./# Production dependencies onlyCOPY package.json .COPY bun.lockb .RUN bun install --production# Set environmentENV NODE_ENV=productionENV LOG_LEVEL=infoCMD ["bun", "run", "index.js"]
Related
- Project Structure - File layout
- Push to Registry - Publishing
- First Processor - Tutorial