Install

This guide provides detailed installation instructions for running the FE&R Decision API on various platforms and environments.

Prerequisites

Before installing, ensure you have:

  • FE&R Credentials: Environment ID and API Key from https://app2.abtasty.com

  • Platform-specific requirements (see each section below)


Run Decision API from Source (Linux and macOS)

Running from source allows you to build and customize the Decision API for your specific needs.

Prerequisites

  • Go 1.23.3 or higher

  • Git

  • Make (optional, for convenience)

Step 2: Clone the Repository

# Clone the Decision API repository
git clone https://github.com/flagship-io/decision-api.git

# Navigate to the project directory
cd decision-api

Step 3: Install Dependencies

# Download Go module dependencies
go mod download

# Verify dependencies
go mod verify

Step 4: Build the Binary

Using Make (Recommended)

# Build the server binary
make build

# The binary will be created at: bin/server

Manual Build

# Create bin directory
mkdir -p bin

# Build the binary
CGO_ENABLED=0 go build -o bin/server cmd/server/*.go

Step 5: Configure Environment Variables

Create a configuration file or set environment variables:

# Option 1: Export environment variables
export ENV_ID=your_env_id
export API_KEY=your_api_key

Or create a .env file:

cat > .env << EOF
ENV_ID=your_env_id
API_KEY=your_api_key
EOF

Step 6: Run the Server

# Run the binary
./bin/server

Run Decision API from Source (Windows)

Prerequisites

  • Go 1.23.3 or higher

  • Git for Windows

  • PowerShell or Command Prompt

Step 3: Clone the Repository

# Clone the repository
git clone https://github.com/flagship-io/decision-api.git

# Navigate to the directory
cd decision-api

Step 4: Install Dependencies

# Download Go module dependencies
go mod download

# Verify dependencies
go mod verify

Step 5: Build the Binary

# Create bin directory
New-Item -ItemType Directory -Force -Path bin

# Build the binary
go build -o bin\server.exe .\cmd\server\

Step 6: Configure Environment Variables

Option 1: Set in PowerShell Session

$env:ENV_ID="your_env_id"
$env:API_KEY="your_api_key"

Option 2: Create a .env file

Create a file named .env in the project root:

ENV_ID=your_env_id
API_KEY=your_api_key

Step 7: Run the Server

# Run the binary
.\bin\server.exe

Run the Decision API using the provided Docker image

Docker provides the easiest way to run the Decision API with minimal setup.

Prerequisites

  • Docker 20.10 or higher

  • Docker Compose (optional, for multi-container setup)

Method 1: Run with Docker (Simple)

# Pull the latest image
docker pull flagshipio/decision-api:latest

# Run the container
docker run -d \
  --name flagship-decision-api \
  -p 8080:8080 \
  -e ENV_ID=your_env_id \
  -e API_KEY=your_api_key \
  -e LOG_LEVEL=info \
  flagshipio/decision-api:latest

Create a docker-compose.yml file:

version: "3.9"
services:
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5
    restart: unless-stopped

  decision-api:
    image: flagshipio/decision-api:latest
    ports:
      - "8080:8080"
    environment:
      # FE&R credentials - UPDATE THESE
      ENV_ID: your_env_id
      API_KEY: your_api_key
      # Server configuration
      LOG_LEVEL: info
      LOG_FORMAT: json
      ADDRESS: ":8080"
      # Cache configuration (Redis for advanced features)
      CACHE_TYPE: redis
      CACHE_OPTIONS_REDISHOST: redis:6379
      # CORS configuration
      CORS_ENABLED: "true"
      CORS_ALLOWED_ORIGINS: "*"
      # Polling interval for config updates
      POLLING_INTERVAL: 60s
    depends_on:
      redis:
        condition: service_healthy
    restart: unless-stopped

volumes:
  redis_data:
    driver: local

networks:
  default:
    name: flagship-demo

Configuration parameters

You can use the following parameters to customize the Decision API. Each parameter is named as in the config.yaml file, and the matching environment variable is parenthesis.

Parameter
Type
Required
Description

env_id (ENV_ID)

string

yes

The Flagship environment ID. You can get it from the Flagship platform. Default to empty string

api_key (API_KEY)

string

yes

The Flagship API Key for this environment ID. You can get it from the Flagship platform. Default to empty string

address (ADDRESS)

string

no

The server address to listen for requests. Default to ":8080"

cors.enabled (CORS_ENABLED)

bool

no

If true, the server will return the cors response headers necessary for cross origins API calls. Default to true

cors.allowed_origins (CORS_ALLOWED_ORIGINS)

string

no

If the cors are enabled, this option will set the Access-Control-Allow-Origin response headers. Default to "*"

log.level (LOG_LEVEL)

string

no

Set the minimum log level that will be send to output. Can be trace, debug, info, warn, error, fatal, panic. Default to "warning"

log.format (LOG_FORMAT)

string

no

Set the output log format. Can be either "text" or "json". Default to "text"

polling_interval (POLLING_INTERVAL)

string

no

The polling frequency (as parsable by the ParseDuration method) to synchronize with your Flagship configuration. Default to 60s

cache.type (CACHE_TYPE)

string

no

If you want to enable caching for the visitor assignment. Can be "memory", "redis", "dynamo" or "local". Default to empty string.

cache.options.dbPath (CACHE_OPTIONS_DBPATH)

string

no

If you chose local cache type, this is the path of the file where the cache will be stored. Default to empty string

cache.options.redisHost (CACHE_OPTIONS_REDISHOST)

string

no

If you chose redis cache type, this is the host for your redis server

cache.options.redisUsername (CACHE_OPTIONS_REDISUSERNAME)

string

no

If you chose redis cache type, this is the username for your redis server

cache.options.redisUsername (CACHE_OPTIONS_REDISPASSWORD)

string

no

If you chose redis cache type, this is the password for your redis server

cache.options.redisDb (CACHE_OPTIONS_REDISDB)

int

no

If you chose redis cache type, this is the db number for your redis server. Default to 0 (default DB)

cache.options.redisTls (CACHE_OPTIONS_REDISTLS)

bool

no

If true, redis client will be set to connect using TLS to the redis server. Default to false

cache.options.dynamoTableName (CACHE_OPTIONS_DYNAMOTABLENAME)

string

no

The table name to store cache assignments when using DynamoDB. Default to "visitor-assignments"

cache.options.dynamoPKSeparator (CACHE_OPTIONS_DYNAMOPKSEPARATOR)

string

no

The primary key separator between env ID & visitor ID to store cache assignments when using DynamoDB. Default to "."

cache.options.dynamoPKField (CACHE_OPTIONS_DYNAMOPKFIELD)

string

no

The primary key field name to store cache assignments when using DynamoDB. Default to "id"

cache.options.dynamoGetTimeout (CACHE_OPTIONS_DYNAMOGETTIMEOUT)

string

no

The timeout for getting previously stored visitor cache assignment when using DynamoDB. Default to 1s

Start the services:

# Start in detached mode
docker compose up -d

Last updated

Was this helpful?