-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add Docker publishing with environment variable conventions #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
d620a43
db8bd17
0a9e81b
beae62c
0c646df
74f0902
9dbafe9
256a87f
344d8f0
bba25e0
5e0cf2c
26333a4
d244e46
d6fedf0
63fbbc8
1cdaeb0
33daec9
45c8518
434cf97
0ade9d9
9551c8b
df1887e
10d773a
2361e05
a9077cb
b73a051
11d4efb
05f8c73
d422353
a144bb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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 | ||
|
|
||
| EXPOSE ${NODE_PORT} | ||
AhmedKorim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # 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}"] | ||
AhmedKorim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,58 @@ | ||
| # 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> | ||
| git clone git@github.com:droq-ai/dfx-base-node-template-py.git | ||
| cd droq-node-template-py | ||
AhmedKorim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 in [droq-node-registry](https://github.com/droq-ai/droq-node-registry) to appear on [directory.droq.ai](https://directory.droq.ai) | ||
AhmedKorim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Development | ||
| ## Configuration | ||
AhmedKorim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```bash | ||
| # Run tests | ||
| PYTHONPATH=src uv run pytest | ||
| ### Node Configuration | ||
|
|
||
| Configure `node.json` with your node metadata. All fields are required: | ||
|
|
||
| - **Identity**: `version`, `node_id`, `name`, `description` | ||
| - **Runtime**: `api_url`, `ip_address`, `docker_image`, `status`, `deployment_location` | ||
| - **Metadata**: `author`, `created_at`, `source_code_location` | ||
| - **Components**: Define your node's functional components | ||
|
|
||
| See [Node Configuration Guide](docs/node-configuration.md) for complete details. | ||
|
|
||
| ### Environment Variables | ||
|
|
||
| Copy `.env.example` to `.env` and configure: | ||
|
|
||
AhmedKorim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| **Required:** | ||
| - `NODE_NAME` - Node identifier | ||
| - `NODE_PORT` - Port inside container (default: 8000) | ||
| - `NATS_URL` - NATS server URL (default: nats://localhost:4222) | ||
| - `STREAM_NAME` - JetStream name (default: droq-stream) | ||
| - `LOG_LEVEL` - Logging level (default: INFO) | ||
|
||
|
|
||
| # Format code | ||
| uv run black src/ tests/ | ||
| uv run ruff check src/ tests/ | ||
|
|
||
| # Add dependencies | ||
| uv add package-name | ||
| ``` | ||
|
|
||
| ## Docker | ||
|
|
||
|
|
@@ -50,32 +61,35 @@ 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 8080:8000 \ | ||
AhmedKorim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| -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 | ||
|
|
||
| - [Node Configuration Guide](docs/node-configuration.md) - Complete node.json setup | ||
| - [Node Registration Guide](docs/node-registration.md) - Register your node in the registry | ||
| - [Usage Guide](docs/usage.md) | ||
| - [NATS Examples](docs/nats.md) | ||
AhmedKorim marked this conversation as resolved.
Show resolved
Hide resolved
AhmedKorim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## License | ||
|
|
||
| Apache License 2.0 | ||
| Apache License 2.0 | ||
There was a problem hiding this comment.
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.