mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-07 06:06:02 +01:00
feat(docker): add LDK Node mint service with dedicated Docker setup (#1108)
* feat(docker): add LDK Node mint service with dedicated Docker setup - Add Dockerfile.ldk-node and Dockerfile.ldk-node.arm for LDK Node builds - Add GitHub Actions workflows for publishing LDK Node Docker images - Add docker-compose.ldk-node.yaml for standalone LDK Node deployment - Integrate LDK Node service into main docker-compose.yaml with profile - Update cdk-mintd README with LDK Node Docker configuration * feat: use docker tags
This commit is contained in:
62
.github/workflows/docker-publish-ldk-node-arm.yml
vendored
Normal file
62
.github/workflows/docker-publish-ldk-node-arm.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
name: Publish Docker Image LDK Node ARM64
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag to build and publish'
|
||||
required: true
|
||||
default: 'latest'
|
||||
|
||||
env:
|
||||
REGISTRY: docker.io
|
||||
IMAGE_NAME: cashubtc/mintd
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=ldk-node-arm64,enable=${{ github.event_name == 'release' }}
|
||||
type=semver,pattern={{version}}-ldk-node-arm64
|
||||
type=semver,pattern={{major}}.{{minor}}-ldk-node-arm64
|
||||
type=ref,event=branch,suffix=-ldk-node-arm64
|
||||
type=ref,event=pr,suffix=-ldk-node-arm64
|
||||
type=sha,suffix=-ldk-node-arm64
|
||||
${{ github.event.inputs.tag != '' && format('{0}-ldk-node-arm64', github.event.inputs.tag) || '' }}
|
||||
|
||||
# Build and push ARM64 image with architecture suffix
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/arm64
|
||||
file: ./Dockerfile.ldk-node.arm
|
||||
tags: ${{ steps.meta.outputs.tags }}-arm64
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
62
.github/workflows/docker-publish-ldk-node.yml
vendored
Normal file
62
.github/workflows/docker-publish-ldk-node.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
name: Publish Docker Image LDK Node AMD64
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag to build and publish'
|
||||
required: true
|
||||
default: 'latest'
|
||||
|
||||
env:
|
||||
REGISTRY: docker.io
|
||||
IMAGE_NAME: cashubtc/mintd
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=ldk-node,enable=${{ github.event_name == 'release' }}
|
||||
type=semver,pattern={{version}}-ldk-node
|
||||
type=semver,pattern={{major}}.{{minor}}-ldk-node
|
||||
type=ref,event=branch,suffix=-ldk-node
|
||||
type=ref,event=pr,suffix=-ldk-node
|
||||
type=sha,suffix=-ldk-node
|
||||
${{ github.event.inputs.tag != '' && format('{0}-ldk-node', github.event.inputs.tag) || '' }}
|
||||
|
||||
# Build and push AMD64 image with architecture suffix
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.ldk-node
|
||||
push: true
|
||||
platforms: linux/amd64
|
||||
tags: ${{ steps.meta.outputs.tags }}-amd64
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
@@ -10,7 +10,7 @@ COPY Cargo.toml ./Cargo.toml
|
||||
COPY crates ./crates
|
||||
|
||||
# Start the Nix daemon and develop the environment
|
||||
RUN nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd --features redis --features prometheus
|
||||
RUN nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd --features postgres --features prometheus
|
||||
|
||||
# Create a runtime stage
|
||||
FROM debian:trixie-slim
|
||||
|
||||
@@ -13,7 +13,7 @@ COPY crates ./crates
|
||||
RUN echo 'filter-syscalls = false' > /etc/nix/nix.conf
|
||||
|
||||
# Start the Nix daemon and develop the environment
|
||||
RUN nix develop --extra-platforms aarch64-linux --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd --features redis
|
||||
RUN nix develop --extra-platforms aarch64-linux --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd --features postgres
|
||||
|
||||
# Create a runtime stage
|
||||
FROM debian:trixie-slim
|
||||
|
||||
40
Dockerfile.ldk-node
Normal file
40
Dockerfile.ldk-node
Normal file
@@ -0,0 +1,40 @@
|
||||
# Use the official NixOS image as the base image
|
||||
FROM nixos/nix:latest AS builder
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy workspace files and crates directory into the container
|
||||
COPY flake.nix ./flake.nix
|
||||
COPY Cargo.toml ./Cargo.toml
|
||||
COPY crates ./crates
|
||||
|
||||
# Start the Nix daemon and develop the environment
|
||||
RUN nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd --features ldk-node --features prometheus --features postgres
|
||||
|
||||
# Create a runtime stage
|
||||
FROM debian:trixie-slim
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install needed runtime dependencies (if any)
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends patchelf && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy the built application from the build stage
|
||||
COPY --from=builder /usr/src/app/target/release/cdk-mintd /usr/local/bin/cdk-mintd
|
||||
|
||||
# Detect the architecture and set the interpreter accordingly
|
||||
RUN ARCH=$(uname -m) && \
|
||||
if [ "$ARCH" = "aarch64" ]; then \
|
||||
patchelf --set-interpreter /lib/ld-linux-aarch64.so.1 /usr/local/bin/cdk-mintd; \
|
||||
elif [ "$ARCH" = "x86_64" ]; then \
|
||||
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /usr/local/bin/cdk-mintd; \
|
||||
else \
|
||||
echo "Unsupported architecture: $ARCH"; exit 1; \
|
||||
fi
|
||||
|
||||
# Set the entry point for the container
|
||||
CMD ["cdk-mintd"]
|
||||
43
Dockerfile.ldk-node.arm
Normal file
43
Dockerfile.ldk-node.arm
Normal file
@@ -0,0 +1,43 @@
|
||||
# Use the official NixOS image as the base image
|
||||
FROM nixos/nix:latest AS builder
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy workspace files and crates directory into the container
|
||||
COPY flake.nix ./flake.nix
|
||||
COPY Cargo.toml ./Cargo.toml
|
||||
COPY crates ./crates
|
||||
|
||||
# Create a nix config file to disable syscall filtering
|
||||
RUN echo 'filter-syscalls = false' > /etc/nix/nix.conf
|
||||
|
||||
# Start the Nix daemon and develop the environment
|
||||
RUN nix develop --extra-platforms aarch64-linux --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd --features ldk-node --features prometheus --features postgres
|
||||
|
||||
# Create a runtime stage
|
||||
FROM debian:trixie-slim
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install needed runtime dependencies (if any)
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends patchelf && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy the built application from the build stage
|
||||
COPY --from=builder /usr/src/app/target/release/cdk-mintd /usr/local/bin/cdk-mintd
|
||||
|
||||
# Detect the architecture and set the interpreter accordingly
|
||||
RUN ARCH=$(uname -m) && \
|
||||
if [ "$ARCH" = "aarch64" ]; then \
|
||||
patchelf --set-interpreter /lib/ld-linux-aarch64.so.1 /usr/local/bin/cdk-mintd; \
|
||||
elif [ "$ARCH" = "x86_64" ]; then \
|
||||
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /usr/local/bin/cdk-mintd; \
|
||||
else \
|
||||
echo "Unsupported architecture: $ARCH"; exit 1; \
|
||||
fi
|
||||
|
||||
# Set the entry point for the container
|
||||
CMD ["cdk-mintd"]
|
||||
@@ -151,6 +151,53 @@ After setup and first run, your directory will look like:
|
||||
- Log directories and files
|
||||
- Lightning backend data directories
|
||||
|
||||
## Docker Usage
|
||||
|
||||
CDK Mintd provides ready-to-use Docker images with multiple Lightning backend options.
|
||||
|
||||
### Quick Start
|
||||
|
||||
#### Standard mint with fakewallet backend (testing only):
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
#### Mint with LDK Node backend:
|
||||
```bash
|
||||
# Option 1: Use dedicated ldk-node compose file
|
||||
docker-compose -f docker-compose.ldk-node.yaml up
|
||||
|
||||
# Option 2: Use main compose file with profile
|
||||
docker-compose --profile ldk-node up
|
||||
```
|
||||
|
||||
### Available Images
|
||||
|
||||
- **`cashubtc/mintd:latest`** - Standard mint with default features
|
||||
- **`cashubtc/mintd-ldk-node:latest`** - Mint with LDK Node support
|
||||
|
||||
### Configuration via Environment Variables
|
||||
|
||||
All configuration can be done through environment variables:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- CDK_MINTD_LN_BACKEND=ldk-node
|
||||
- CDK_MINTD_DATABASE=sqlite
|
||||
- CDK_MINTD_LISTEN_HOST=0.0.0.0
|
||||
- CDK_MINTD_LISTEN_PORT=8085
|
||||
- CDK_MINTD_LDK_NODE_NETWORK=testnet
|
||||
- CDK_MINTD_LDK_NODE_ESPLORA_URL=https://blockstream.info/testnet/api
|
||||
```
|
||||
|
||||
### Monitoring
|
||||
|
||||
Both Prometheus metrics and Grafana dashboards are included:
|
||||
- Prometheus: http://localhost:9090
|
||||
- Grafana: http://localhost:3011 (admin/admin)
|
||||
|
||||
For detailed Docker documentation, see [README-ldk-node.md](../../README-ldk-node.md).
|
||||
|
||||
## Testing Your Mint
|
||||
|
||||
1. **Verify the mint is running**:
|
||||
|
||||
118
docker-compose.ldk-node.yaml
Normal file
118
docker-compose.ldk-node.yaml
Normal file
@@ -0,0 +1,118 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# CDK Mint service with LDK Node backend
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
ports:
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
- ./misc/provisioning/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--storage.tsdb.path=/prometheus'
|
||||
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
||||
- '--web.console.templates=/etc/prometheus/consoles'
|
||||
- '--web.enable-lifecycle'
|
||||
- '--enable-feature=otlp-write-receiver'
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
networks:
|
||||
- cdk
|
||||
|
||||
# Grafana for visualization
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
ports:
|
||||
- "3011:3000"
|
||||
volumes:
|
||||
- ./misc/provisioning/datasources:/etc/grafana/provisioning/datasources
|
||||
- ./misc/provisioning/dashboards:/etc/grafana/provisioning/dashboards
|
||||
environment:
|
||||
- GF_DASHBOARDS_JSON_ENABLED=true
|
||||
- GF_SECURITY_ADMIN_PASSWORD=admin
|
||||
- GF_PROVISIONING_PATHS=/etc/grafana/provisioning
|
||||
networks:
|
||||
- cdk
|
||||
|
||||
mintd-ldk-node:
|
||||
# Use the ldk-node tagged image from the same repository
|
||||
image: cashubtc/mintd:ldk-node-amd64
|
||||
# Alternatively, build locally:
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: Dockerfile.ldk-node
|
||||
container_name: mint-ldk-node
|
||||
ports:
|
||||
- "8085:8085"
|
||||
environment:
|
||||
- CDK_MINTD_URL=https://example.com
|
||||
- CDK_MINTD_LN_BACKEND=ldk-node
|
||||
- CDK_MINTD_LISTEN_HOST=0.0.0.0
|
||||
- CDK_MINTD_LISTEN_PORT=8085
|
||||
- CDK_MINTD_MNEMONIC=
|
||||
# Database configuration - choose one:
|
||||
# Option 1: SQLite (embedded, no additional setup needed)
|
||||
- CDK_MINTD_DATABASE=sqlite
|
||||
# Option 2: ReDB (embedded, no additional setup needed)
|
||||
# - CDK_MINTD_DATABASE=redb
|
||||
# Option 3: PostgreSQL (requires postgres service, enable with: docker-compose --profile postgres up)
|
||||
# - CDK_MINTD_DATABASE=postgres
|
||||
# - CDK_MINTD_DATABASE_URL=postgresql://cdk_user:cdk_password@postgres:5432/cdk_mint
|
||||
# Cache configuration
|
||||
- CDK_MINTD_CACHE_BACKEND=memory
|
||||
- CDK_MINTD_PROMETHEUS_ENABLED=true
|
||||
- CDK_MINTD_PROMETHEUS_ADDRESS=0.0.0.0
|
||||
- CDK_MINTD_PROMETHEUS_PORT=9000
|
||||
# LDK Node specific configuration
|
||||
- CDK_MINTD_LDK_NODE_NETWORK=testnet
|
||||
- CDK_MINTD_LDK_NODE_ESPLORA_URL=https://blockstream.info/testnet/api
|
||||
- CDK_MINTD_LDK_NODE_LISTENING_ADDRESSES=0.0.0.0:9735
|
||||
volumes:
|
||||
# Persist LDK node data
|
||||
- ldk_node_data:/usr/src/app/ldk_node_data
|
||||
command: ["cdk-mintd"]
|
||||
depends_on:
|
||||
- prometheus
|
||||
- grafana
|
||||
networks:
|
||||
- cdk
|
||||
# Uncomment when using PostgreSQL:
|
||||
# depends_on:
|
||||
# - postgres
|
||||
|
||||
# PostgreSQL database service
|
||||
# Enable with: docker-compose --profile postgres up
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: mint_postgres
|
||||
restart: unless-stopped
|
||||
profiles:
|
||||
- postgres
|
||||
environment:
|
||||
- POSTGRES_USER=cdk_user
|
||||
- POSTGRES_PASSWORD=cdk_password
|
||||
- POSTGRES_DB=cdk_mint
|
||||
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U cdk_user -d cdk_mint"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- cdk
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
ldk_node_data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
cdk:
|
||||
driver: bridge
|
||||
@@ -71,6 +71,43 @@ services:
|
||||
# depends_on:
|
||||
# - postgres
|
||||
|
||||
# LDK Node mint service - enable with: docker-compose --profile ldk-node up
|
||||
mintd-ldk-node:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.ldk-node
|
||||
container_name: mint-ldk-node
|
||||
profiles:
|
||||
- ldk-node
|
||||
ports:
|
||||
- "8086:8085" # Different port to avoid conflict with main mint
|
||||
environment:
|
||||
- CDK_MINTD_URL=https://example.com
|
||||
- CDK_MINTD_LN_BACKEND=ldk-node
|
||||
- CDK_MINTD_LISTEN_HOST=0.0.0.0
|
||||
- CDK_MINTD_LISTEN_PORT=8085
|
||||
- CDK_MINTD_MNEMONIC=
|
||||
# Database configuration
|
||||
- CDK_MINTD_DATABASE=sqlite
|
||||
# Cache configuration
|
||||
- CDK_MINTD_CACHE_BACKEND=memory
|
||||
- CDK_MINTD_PROMETHEUS_ENABLED=true
|
||||
- CDK_MINTD_PROMETHEUS_ADDRESS=0.0.0.0
|
||||
- CDK_MINTD_PROMETHEUS_PORT=9000
|
||||
# LDK Node specific configuration
|
||||
- CDK_MINTD_LDK_NODE_NETWORK=testnet
|
||||
- CDK_MINTD_LDK_NODE_ESPLORA_URL=https://blockstream.info/testnet/api
|
||||
- CDK_MINTD_LDK_NODE_LISTENING_ADDRESSES=0.0.0.0:9735
|
||||
volumes:
|
||||
# Persist LDK node data
|
||||
- ldk_node_data:/usr/src/app/ldk_node_data
|
||||
command: ["cdk-mintd"]
|
||||
depends_on:
|
||||
- prometheus
|
||||
- grafana
|
||||
networks:
|
||||
- cdk
|
||||
|
||||
# PostgreSQL database service
|
||||
# Enable with: docker-compose --profile postgres up
|
||||
# postgres:
|
||||
@@ -99,6 +136,8 @@ services:
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
ldk_node_data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
cdk:
|
||||
|
||||
Reference in New Issue
Block a user