Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d620a43
feat: add docker publishing with environment variable conventions
AhmedKorim Nov 18, 2025
db8bd17
feat: prevent Docker publishing from template repository
AhmedKorim Nov 18, 2025
0a9e81b
Update README.md
AhmedKorim Nov 19, 2025
beae62c
clean up docker publishing
AhmedKorim Nov 19, 2025
0c646df
Merge remote-tracking branch 'origin/ahmed/feat/docker-registry-templ…
AhmedKorim Nov 19, 2025
74f0902
update def for `node.json`
AhmedKorim Nov 19, 2025
9dbafe9
sync doc for `node.json`
AhmedKorim Nov 19, 2025
256a87f
sync readme and remove unwanted docker args
AhmedKorim Nov 19, 2025
344d8f0
chore: registration documented
AhmedKorim Nov 19, 2025
bba25e0
remove docker publish guide
AhmedKorim Nov 19, 2025
5e0cf2c
remove docker publish guide
AhmedKorim Nov 19, 2025
26333a4
remove the recommend structure for the component paths
AhmedKorim Nov 19, 2025
d244e46
Update docs/node-configuration.md
AhmedKorim Nov 19, 2025
d6fedf0
Update README.md
AhmedKorim Nov 19, 2025
63fbbc8
Update README.md
AhmedKorim Nov 19, 2025
1cdaeb0
Update README.md
AhmedKorim Nov 19, 2025
33daec9
Update README.md
AhmedKorim Nov 19, 2025
45c8518
Update README.md
AhmedKorim Nov 19, 2025
434cf97
Update node.json
AhmedKorim Nov 19, 2025
0ade9d9
Update docs/node-configuration.md
AhmedKorim Nov 19, 2025
9551c8b
Update README.md
AhmedKorim Nov 19, 2025
df1887e
Update docs/node-configuration.md
AhmedKorim Nov 19, 2025
10d773a
Update README.md
AhmedKorim Nov 19, 2025
2361e05
remove ghcr from examples
AhmedKorim Nov 19, 2025
a9077cb
Remove component suggested strucutre
AhmedKorim Nov 19, 2025
b73a051
Remove ghcr
AhmedKorim Nov 19, 2025
11d4efb
Merge remote-tracking branch 'origin/ahmed/feat/docker-registry-templ…
AhmedKorim Nov 19, 2025
05f8c73
Update docs/node-configuration.md
0x3bfc Nov 19, 2025
d422353
Update README.md
0x3bfc Nov 19, 2025
a144bb6
Update docs/node-configuration.md
0x3bfc Nov 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
# Droq Node Template Environment Variables
# Copy this file to .env and update with your values
# Environment Variable Naming Convention:
# NODE_ - Node configuration
# NATS_ - NATS configuration
# LOG_ - Logging configuration
# DB_ - Database configuration
# HTTP_ - HTTP client configuration
# SERVICE_ - Service-specific configuration
# METRICS_ - Metrics and monitoring

# Node Configuration
NODE_NAME=droq-node-template
NODE_PORT=8000
NODE_EXTERNAL_PORT=8000
NODE_HEALTH_CHECK_ENABLED=true

# Logging
LOG_LEVEL=INFO

# NATS Configuration
NATS_URL=nats://localhost:4222
NATS_CLIENT_NAME=${NODE_NAME:-droq-node-template}
STREAM_NAME=droq-stream

# HTTP Client Configuration (optional)
# BASE_URL=https://api.example.com
# Optional: NATS Authentication
# NATS_USERNAME=nats-user
# NATS_PASSWORD=nats-pass

# Optional: HTTP Configuration
# HTTP_BASE_URL=https://api.example.com
# HTTP_API_KEY=your-api-key

# Optional: Database Configuration
# DB_URL=postgresql://user:pass@localhost/dbname

# Add your custom environment variables below
# API_KEY=your-api-key-here
# DATABASE_URL=postgresql://user:pass@localhost/dbname
# Optional: Metrics Configuration
# METRICS_PORT=8081
# METRICS_ENABLED=true
33 changes: 6 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,28 @@
# Dockerfile template for Droq nodes
# This is an agnostic template - customize as needed for your node

FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Install system dependencies
# Uncomment and add system packages as needed:
# RUN apt-get update && apt-get install -y \
# gcc \
# g++ \
# make \
# curl \
# && rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Copy dependency files
COPY pyproject.toml uv.lock* ./

# Install dependencies using uv
# Install dependencies directly (not as editable package)
RUN uv pip install --system nats-py aiohttp || \
(uv pip compile pyproject.toml -o requirements.txt && \
uv pip install --system -r requirements.txt)

# Copy source code
COPY src/ ./src/

# Create non-root user for security
RUN useradd -m -u 1000 nodeuser && chown -R nodeuser:nodeuser /app
USER nodeuser

# Set environment variables
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV NODE_PORT=8000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't hardcode this port in the dockerfile, the compose should handle this.


EXPOSE ${NODE_PORT}

# Optional: Health check
# Uncomment and customize as needed:
# HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
# CMD python -c "import sys; sys.exit(0)"
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import sys; sys.exit(0)" || exit 1

# Run the node
# Update this command to match your entry point
CMD ["uv", "run", "python", "-m", "node.main"]
CMD ["sh", "-c", "exec uv run python -m node.main --port=${NODE_PORT:-8000}"]

77 changes: 34 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,36 @@
# Droq Node Template

A Python template for building Droq nodes. Works with any Python code - minimal updates needed.
A Python template for building Droqflow nodes.

## Quick Start

```bash
# 1. Clone and setup
git clone <repository-url>
cd droq-node-template-py
git clone git@github.com:droq-ai/dfx-base-node-template-py.git
cd dfx-base-node-template-py
uv sync

# 2. Replace src/node/main.py with your code
# Replace src/node/main.py with your code
# Add dependencies: uv add your-package

# 3. Add dependencies
uv add your-package
# Configure node.json with your node information
# Configure environment variables

# 4. Test locally
# Test locally
PYTHONPATH=src uv run python -m node.main
# or
docker compose up

# 5. Build
docker build -t your-node:latest .
# Run with Docker
docker compose up
```

## Documentation
## Next Steps

- [Usage Guide](docs/usage.md) - How to use the template
- [NATS Examples](docs/nats.md) - NATS publishing and consuming examples
1. Complete your node development
2. Configure [node.json](docs/node-configuration.md) with your node metadata
3. Register your node [TBD]

## Development

```bash
# Run tests
PYTHONPATH=src uv run pytest

# Format code
uv run black src/ tests/
uv run ruff check src/ tests/

# Add dependencies
uv add package-name
```

## Docker

Expand All @@ -50,32 +39,34 @@ uv add package-name
docker build -t your-node:latest .

# Run
docker run --rm your-node:latest

# Development (with hot reload)
docker compose up
docker run -p 8000:8000 \
-e NODE_NAME=my-node \
-e NATS_URL=nats://localhost:4222 \
your-node:latest
```

## Environment Variables

Copy `.env.example` to `.env` and update with your values:
## Development

```bash
cp .env.example .env
# Run tests
PYTHONPATH=src uv run pytest

# Format code
uv run black src/ tests/
uv run ruff check src/ tests/

# Add dependencies
uv add package-name
```

Or set in `compose.yml` or pass to Docker:
- `NATS_URL` - NATS server URL (default: `nats://localhost:4222`)
- `STREAM_NAME` - JetStream name (default: `droq-stream`)
- `NODE_NAME` - Node identifier
- `LOG_LEVEL` - Logging level

## Next Steps

1. Test locally
2. Build Docker image
3. Register metadata in `droq-node-registry` (separate repo)
## Documentation

- [Usage Guide](docs/usage.md)
- [Configuration Guide](docs/node-configuration.md)
- [NATS Examples](docs/nats.md)

## License

Apache License 2.0
Apache License 2.0
20 changes: 6 additions & 14 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,25 @@ services:
container_name: droq-node-template
environment:
- NODE_NAME=droq-node-template
- NODE_PORT=8000
- LOG_LEVEL=INFO
- NATS_URL=nats://nats:4222
- NATS_CLIENT_NAME=${NODE_NAME:-droq-node-template}
- STREAM_NAME=droq-stream
# Add your environment variables here
# - API_KEY=${API_KEY}
# - DATABASE_URL=${DATABASE_URL}
# - BASE_URL=https://api.example.com
volumes:
# Mount source code for development (hot reload)
- ./src:/app/src:ro
# Mount additional volumes as needed
# - ./data:/app/data
networks:
- droq-network
restart: unless-stopped
# Uncomment to expose ports if your node needs them
# ports:
# - "8080:8080"
ports:
- "${NODE_EXTERNAL_PORT:-8000}:${NODE_PORT:-8000}"

# NATS server for local development and testing
nats:
image: nats:latest
container_name: droq-nats
ports:
- "4222:4222" # Client connections
- "8222:8222" # HTTP monitoring
- "6222:6222" # Cluster routing
- "4222:4222"
- "8222:8222"
command: ["-js", "-m", "8222"]
networks:
- droq-network
Expand Down
Loading