Menu

Docker Deployment Overview

Docker deployment is the recommended approach for running ApiCharge in production environments. It provides consistent operation across different platforms, simplified management, and scalability options.

Early Access Notice: The ApiCharge Docker image is currently available exclusively through our Early Access Program. Contact our team for information on accessing these images.

Key Features of Docker Deployment

Deployment Options

ApiCharge Docker images support two primary deployment scenarios:

1. Single Container with Embedded Services

The simplest deployment option includes everything needed to run ApiCharge in a single container:

This approach is ideal for:

2. Clustered Deployment with External Services

For larger-scale production deployments, you can run multiple ApiCharge containers that share external dependencies:

This approach is recommended for:

For detailed information on clustering, see the Clustering documentation.

Network Configuration

ApiCharge Docker images are available for both Stellar Testnet and Mainnet configurations:

The images are pre-configured with appropriate network settings, but you'll need to provide your own Stellar account credentials via environment variables.

Basic Deployment with Docker Compose

The recommended way to deploy ApiCharge is using Docker Compose. Here's a basic example of a docker-compose.yml file:

version: '3.8'

services:
  apicharge-stellar-rpc:
    image: apicharge-stellar-rpc:testnet  # or :mainnet for production
    container_name: apicharge-stellar-rpc
    ports:
      - "8080:80"   # HTTP
      - "8443:443"  # HTTPS
    volumes:
      - ./certs:/certs:ro                        # SSL certificates
      - apicharge-redis-data:/data/redis         # Redis data
      - soroban-data:/var/lib/stellar            # Stellar blockchain data
    env_file:
      - ./.env                                   # Environment variables
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
    restart: unless-stopped
    networks:
      - apicharge-network

networks:
  apicharge-network:
    driver: bridge

volumes:
  apicharge-redis-data:
  soroban-data:

Environment Configuration

ApiCharge requires several environment variables to be set. Create a .env file with the following variables:

# Required Stellar account credentials
APICHARGE_SIGNING_KEY=SDH3X...YOUR_STELLAR_SECRET_KEY
APICHARGE_NETWORK_PASSPHRASE=Test SDF Network ; September 2015  # for testnet

# Optional configuration
APICHARGE_USE_EMBEDDED_REDIS=true  # Set to false if using external Redis
ASPNETCORE_URLS=http://+:80;https://+:443
Security Notice: The .env file contains sensitive information. Ensure it has appropriate permissions and is not committed to version control.

Volume Persistence

ApiCharge uses Docker volumes to persist data across container restarts:

These volumes ensure that your data is preserved even if the container is stopped or restarted.

Customizing Configuration

You can override the default configuration by mounting your own appsettings.json file:

volumes:
  - ./appsettings.json:/app/appsettings.json:ro  # Custom configuration

This allows you to customize routes, rate limiters, and other settings without rebuilding the Docker image.

Clustered Deployment Example

For production environments with multiple ApiCharge instances, use a configuration like this:

version: '3.8'

services:
  apicharge1:
    image: apicharge-stellar-rpc:mainnet
    container_name: apicharge1
    ports:
      - "8080:80"
      - "8443:443"
    volumes:
      - ./certs:/certs:ro
      - soroban-data1:/var/lib/stellar
    env_file:
      - ./.env
    environment:
      - APICHARGE_USE_EMBEDDED_REDIS=false
      - ASPNETCORE_ENVIRONMENT=Production
    restart: unless-stopped
    networks:
      - apicharge-network
    depends_on:
      - redis

  apicharge2:
    image: apicharge-stellar-rpc:mainnet
    container_name: apicharge2
    ports:
      - "8081:80"
      - "8444:443"
    volumes:
      - ./certs:/certs:ro
      - soroban-data2:/var/lib/stellar
    env_file:
      - ./.env
    environment:
      - APICHARGE_USE_EMBEDDED_REDIS=false
      - ASPNETCORE_ENVIRONMENT=Production
    restart: unless-stopped
    networks:
      - apicharge-network
    depends_on:
      - redis

  redis:
    image: redis:latest
    container_name: apicharge-redis
    command: redis-server --appendonly yes --maxmemory 1gb --maxmemory-policy allkeys-lru
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    restart: unless-stopped
    networks:
      - apicharge-network

networks:
  apicharge-network:
    driver: bridge

volumes:
  soroban-data1:
  soroban-data2:
  redis-data:

In this configuration:

You would typically place a load balancer in front of these instances to distribute traffic.

Monitoring and Logging

Docker deployment makes it easy to collect logs and monitor the service:

For more information on logging configuration, see the Logging documentation.

Upgrading

To upgrade to a newer version of ApiCharge:

  1. Pull the latest Docker image (requires Early Access credentials)
  2. Stop the running container with docker-compose down
  3. Start the new container with docker-compose up -d

Your data will be preserved in the Docker volumes, allowing for seamless upgrades.

Next Steps

To learn more about deploying ApiCharge: