FusionAuth Container Deployment

repository·develop·Indexed 42 days ago

https://github.com/fusionauth/fusionauth-containers

Containerized deployment configurations for FusionAuth, including Docker, Docker Compose, Kubernetes (via Helm), and OpenShift. Includes setups for core services like PostgreSQL and OpenSearch, as well as optional profiles for Caddy, Mailcatcher, Kafka, Cleanspeak, and a monitoring stack featuring OpenTelemetry, Prometheus, and Alertmanager.

Tokens
2.3K
Snippets
7
Records
12
Agent score
52%

What's inside FusionAuth

  1. Use Docker Compose with optional profiles

    develop

    The reference docker-compose.yml defaults to using OpenSearch as the search engine. You can enable optional services using the --profile switch in the Docker Compose command. You can use the switch multiple times to enable several profiles at once.

    Available profiles:

    • caddy: Enables a Caddy service configured to proxy to FusionAuth on ports 80 and 443.
    • mailcatcher: Enables Mailcatcher, a test SMTP server for development and testing.
    • kafka: Enables Kafka (and Zookeeper) for receiving Webhook events.
    • cleanspeak: Enables Cleanspeak for filtering usernames and profile data for profanity.
    • opentelemetry: Enables an OpenTelemetry Collector for monitoring.
    • prometheus: Enables Prometheus (can be connected to OpenTelemetry).
    • alertmanager: Enables AlertManager to generate alerts for anomalies and errors.
    docker compose --profile caddy --profile kafka up
  2. Set up FusionAuth monitoring with Docker Compose

    develop

    A specialized Docker Compose configuration is available for setting up a monitoring stack. This setup includes OpenTelemetry, Prometheus, and Alert Manager.

    Location: docker/fusionauth/monitoring/docker-compose.yml

    This directory also contains configuration files for these services. For more detailed operational guidance, refer to the official documentation for OpenTelemetry and Prometheus.

  3. Enable optional FusionAuth services via Docker Compose profiles

    develop

    The docker-compose.yml file uses Docker Compose profiles to manage optional services. To run these services, you must specify the corresponding profile when starting your containers.

    Available Profiles and Services

    • caddy: Runs a Caddy proxy for FusionAuth. Requires a local ./Caddyfile.
    • mailcatcher: Runs an SMTP server for development/testing. Accessible at localhost:1025 (SMTP) and localhost:1080 (Web UI).
    • kafka: Enables Kafka-based Webhooks. Includes both zookeeper and kafka services.
    • cleanspeak: Enables profanity filtering. Requires a LICENSE_ID and CLEANSPEAK_APP_MEMORY configuration.
    • opentelemetry: Collects metrics via OpenTelemetry. Requires a local configuration file mapped via ${OPENTELEMETRY_COLLECTOR_CONFIG_FILE}.
    • prometheus: Enables monitoring via Prometheus. Requires configuration files for ${PROMETHEUS_CONFIG_FILE} and ${PROMETHEUS_RULES_FILE}.
    • alertmanager: Handles alerts in conjunction with Prometheus. Requires ${ALERTMANAGER_CONFIG_FILE}.
  4. Configure FusionAuth core services via Docker Compose

    develop

    The core FusionAuth deployment requires a database and the FusionAuth application itself. By default, the setup uses PostgreSQL and OpenSearch.

    Required Services

    • db: A PostgreSQL container. It uses environment variables ${POSTGRES_USER} and ${POSTGRES_PASSWORD} for authentication.
    • fusionauth: The main application container. It depends on both db and search being healthy.
    • search: An OpenSearch container used for search functionality.

    Switching Search Engine

    You can disable the OpenSearch service and use the database as the search backend by setting SEARCH_TYPE to database in your .env file. If you do this, you must remove the search dependency from the fusionauth service in the docker-compose.yml file.

    services:
      db:
        image: postgres:16.0-bookworm
        environment:
          POSTGRES_USER: ${POSTGRES_USER}
          POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    
      fusionauth:
        image: fusionauth/fusionauth-app:latest
        depends_on:
          db:
            condition: service_healthy
          search:
            condition: service_healthy
        environment:
          DATABASE_URL: jdbc:postgresql://db:5432/fusionauth
          SEARCH_TYPE: ${FUSIONAUTH_SEARCH_TYPE}
    
      search:
        image: opensearchproject/opensearch:2.11.0
  5. Configure Alertmanager

    develop

    Alertmanager works in conjunction with Prometheus to handle and manage alerts. You must provide a configuration file via the ALERTMANAGER_CONFIG_FILE environment variable, which is mounted to /etc/alertmanager/alertmanager-config.yml inside the container.

    Ports:

    • 9093: Alertmanager web UI
    # Example environment variable setup
    ALERTMANAGER_CONFIG_FILE: ./alertmanager-config.yml
  6. Configure Cleanspeak for profanity filtering

    develop

    Cleanspeak provides filtering of usernames and profile data. To use it in a containerized environment, you must provide a Cleanspeak license and configure the following environment variables in the cleanspeak service:

    • DATABASE_URL: jdbc:postgresql://db:5432/cleanspeak
    • DATABASE_ROOT_USERNAME: ${POSTGRES_USER}
    • DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD}
    • DATABASE_USERNAME: ${DATABASE_USER}
    • DATABASE_PASSWORD: ${DATABASE_PASSWORD}
    • CLEANSPEAK_APP_MEMORY: ${CLEANSPEAK_APP_MEMORY}
    • LICENSE_ID: ${CLEANSPEAK_LICENSE_ID}
    • SEARCH_SERVERS: http://search:9200
    cleanspeak:
      image: cleanspeak/cleanspeak-app:latest
      profiles:
        - cleanspeak
      environment:
        DATABASE_URL: jdbc:postgresql://db:5432/cleanspeak
        LICENSE_ID: ${CLEANSPEAK_LICENSE_ID}
        SEARCH_SERVERS: http://search:9200
  7. Configure OpenTelemetry Collector

    develop

    The OpenTelemetry service collects metrics from FusionAuth and can push them to Prometheus or other systems. To customize the collector's behavior, you must provide a configuration file via the OPENTELEMETRY_COLLECTOR_CONFIG_FILE environment variable, which is mounted to /etc/opentelemetry/collector-config.yml inside the container.

    Ports:

    • 8889: Internal collector metrics
    • 4318: OTLP HTTP receiver
    # Example environment variable setup
    OPENTELEMETRY_COLLECTOR_CONFIG_FILE: ./path/to/your/opentelemetry-collector-config.yml
  8. Configure Prometheus monitoring

    develop

    Prometheus can monitor FusionAuth either directly or via OpenTelemetry. Configuration is managed through two primary environment variables that map to files inside the container:

    • PROMETHEUS_CONFIG_FILE: Points to the main Prometheus configuration file (mounted to /etc/prometheus/prometheus.yml).
    • PROMETHEUS_RULES_FILE: Points to the Prometheus alerting rules file (mounted to /etc/prometheus/rules.yml).

    Ports:

    • 9090: Prometheus web UI and API
    # Example environment variable setup
    PROMETHEUS_CONFIG_FILE: ./prometheus.yml
    PROMETHEUS_RULES_FILE: ./rules.yml
  9. Configure FusionAuth environment variables

    develop

    The fusionauth service is configured via several environment variables, many of which should be mapped from a .env file:

    VariableDescription
    DATABASE_URLJDBC connection string (defaults to jdbc:postgresql://db:5432/fusionauth)
    DATABASE_ROOT_USERNAMERoot database username (mapped from ${POSTGRES_USER})
    DATABASE_ROOT_PASSWORDRoot database password (mapped from ${POSTGRES_PASSWORD})
    DATABASE_USERNAMEApplication database username (mapped from ${DATABASE_USER})
    DATABASE_PASSWORDApplication database password (mapped from ${DATABASE_PASSWORD})
    FUSIONAUTH_APP_KICKSTART_FILEPath to the kickstart file (mapped from ${FUSIONAUTH_APP_KICKSTART_FILE})
    FUSIONAUTH_APP_MEMORYMemory limit for the application
    FUSIONAUTH_APP_RUNTIME_MODEThe runtime mode of the application
    FUSIONAUTH_APP_URLThe application URL (defaults to http://fusionauth:9011)
    SEARCH_SERVERSOpenSearch endpoint (defaults to http://search:9200)
    SEARCH_TYPEThe search engine type (e.g., opensearch or database, mapped from ${FUSIONAUTH_SEARCH_TYPE})
    FUSIONAUTH_APP_INSTALLATION_SOURCESet to fusionauth-containers