Investbrain Documentation
Running your own instance

Self-Hosting

Install with the supported Docker Compose file, then configure, update, and maintain your instance.

On this page 24

The only supported way to self-host Investbrain is with the official Docker image and the docker-compose.yml file in this repository. It bundles everything you need: the web app, a background queue, a task scheduler, PostgreSQL, and Redis.

If you'd rather not run a server, Investbrain Cloud runs the same app with nothing to install or manage.

Installation

1. Download the compose file

bash
mkdir investbrain && cd investbrain
curl -O https://raw.githubusercontent.com/investbrainapp/investbrain/main/docker-compose.yml

2. Review the settings

Open docker-compose.yml and adjust the environment section of the app service. At a minimum:

  • Set APP_URL to the address you'll use to reach Investbrain, for example http://192.168.1.50:8000 or https://investbrain.home.
  • Change DB_PASSWORD from the default. If you change any of DB_DATABASE, DB_USERNAME, or DB_PASSWORD, make the same change to POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD in the pgsql service (they must match, and they only take effect the first time the database volume is created).

See Configuration for everything else you can set.

3. Start Investbrain

bash
docker compose up -d

The first start pulls the images and runs database migrations, which can take a few minutes. Follow along with:

bash
docker compose logs -f app

When you see Supervisor start, Investbrain is ready!

4. Create your account

Visit http://localhost:8000/register (or your APP_URL followed by /register) and create an account.

Register your own account first. The first account registered is the only one that can see the Provider Health page.

5. Optional: turn off registration

If you're the only user, or you'd rather invite people by sharing a portfolio, set REGISTRATION_ENABLED: false and apply the change. Shared users can still set a password through their invitation link.

What's in the compose file

Service Container Image Purpose
app investbrain-app investbrainapp/investbrain:latest Nginx, PHP-FPM, the scheduler, and two queue workers, all managed by Supervisor inside one container
pgsql investbrain-pgsql postgres:15-alpine The database
redis investbrain-redis redis:alpine Cache, sessions, and the job queue

Three named volumes keep your data across restarts and upgrades:

Volume Mounted at Contains
investbrain-storage /var/app/storage in app Logs, uploads, the auto-generated APP_KEY (storage/app/.key), and the OAuth signing keys (storage/oauth-*.key)
investbrain-pgsql /var/lib/postgresql/data in pgsql All portfolio, transaction, and user data
investbrain-redis /data in redis Cache and queued jobs

What happens on startup

Every time the app container starts, the entrypoint script:

  1. Creates any missing folders under storage and fixes their permissions.
  2. Checks for an APP_KEY. If none is set in the environment and storage/app/.key doesn't exist, it generates one, saves it to storage/app/.key, and prints it in the log inside a box of asterisks.
  3. Generates OAuth signing keys (storage/oauth-private.key and storage/oauth-public.key) if they don't exist. These are used for API tokens and MCP authorization.
  4. Runs database migrations, retrying every 5 seconds for up to a minute while the database starts. If the database still isn't reachable, the container exits.
  5. Clears and rebuilds caches.
  6. Starts Supervisor, which runs Nginx, PHP-FPM, the scheduler, and two queue workers.

The image also has a health check that requests /up every 30 seconds. docker ps shows the container as healthy once it's serving requests.

Configuration

Where to put settings

You can configure Investbrain in one of two ways. Pick one, don't mix them!

  • The environment block in docker-compose.yml (recommended). Everything lives in one file.
  • An env file. Create a .env file next to docker-compose.yml (use .env.example as a starting point), remove the environment block from the app service, and add env_file: .env in its place.

Applying configuration changes

Settings are read when the container starts. After changing them, recreate the container:

bash
docker compose up -d

docker compose restart is not enough when you edit docker-compose.yml, because it restarts the existing container with its old environment. docker compose up -d recreates the container with the new values.

Options

Application

Option Description Default
APP_URL The full public address of your instance. Used in emails, invitation links, and generated URLs. http://localhost (http://localhost:8000 in the compose file)
ASSET_URL The base address for CSS, JavaScript, and images. Set it to the same value as APP_URL if styling is broken when you use a domain name. Same host as the request
APP_KEY Encryption key. Leave unset to have one generated and stored in the storage volume. If you set it yourself, generate it with openssl rand -base64 32 and prefix it with base64:. Never change it once you have data. Generated on first start
APP_TIMEZONE Time zone for the scheduler, including when daily snapshots are captured. Use a tz database name such as America/New_York. UTC
APP_DEBUG Show detailed error pages. Only turn this on briefly while troubleshooting. false
REGISTRATION_ENABLED Allow new people to register. true
SESSION_LIFETIME Minutes of inactivity before you're signed out. 120

Market data

Option Description Default
MARKET_DATA_PROVIDER One provider, or a comma-separated list for automatic fallback. See Market data providers. yahoo
MARKET_DATA_REFRESH How many minutes before a symbol's price is considered stale and refreshed. 30
DAILY_CHANGE_TIME Time of day (24-hour, in APP_TIMEZONE) to capture each portfolio's daily snapshot on weekdays. 23:00
ALPHAVANTAGE_API_KEY Required for the alphavantage provider. none
FINNHUB_API_KEY Required for the finnhub provider. none
ALPACA_API_KEY, ALPACA_API_SECRET Required for the alpaca provider. none
TWELVEDATA_API_SECRET Required for the twelvedata provider. none

Currency

Option Description Default
BASE_CURRENCY The currency Investbrain stores converted values in internally. See Currency before changing it. USD

MCP server

Option Description Default
MCP_SERVER_ENABLED Turn the built-in MCP server for AI assistants on or off. See Turning off the MCP server. true

AI chat

Option Description Default
AI_CHAT_ENABLED Show the AI chat window on portfolio and holding pages. false
CHAT_PROVIDER One of openai, anthropic, gemini, azure, groq, xai, deepseek, mistral, ollama. openai
CHAT_MODEL The model to use. Leave unset to use the provider's default. Provider default
OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, XAI_API_KEY, DEEPSEEK_API_KEY, MISTRAL_API_KEY API key for the provider you chose. none
AZURE_OPENAI_API_KEY, AZURE_OPENAI_URL, AZURE_OPENAI_API_VERSION, AZURE_OPENAI_DEPLOYMENT Settings for Azure OpenAI. none
OLLAMA_BASE_URL, OLLAMA_API_KEY Address (and optional key) of your Ollama or other OpenAI-compatible server. http://localhost:11434

Social login

Option Description Default
ENABLED_LOGIN_PROVIDERS Comma-separated list of github, google, facebook, linkedin-openid, oidc. none
SSO_AUTO_PROVISION Create a new Investbrain account when someone signs in with any login provider and no account has their email. true
GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET GitHub OAuth app credentials. none
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET Google OAuth client credentials. none
FACEBOOK_CLIENT_ID, FACEBOOK_CLIENT_SECRET Facebook app credentials. none
LINKEDIN_CLIENT_ID, LINKEDIN_CLIENT_SECRET LinkedIn app credentials. none
OIDC_ISSUER Issuer URL of your OpenID Connect provider. none
OIDC_CLIENT_ID, OIDC_CLIENT_SECRET OpenID Connect client credentials. none
OIDC_NAME Name shown on the Login with ... button. SSO
OIDC_BUTTON_COLOR Background color of the login button. #4b5563

Email

Option Description Default
MAIL_MAILER smtp to send real email, or log to write emails to the log file instead. log
MAIL_HOST, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD, MAIL_ENCRYPTION SMTP server settings. none
MAIL_FROM_ADDRESS, MAIL_FROM_NAME Sender address and name. hello@example.com, Investbrain

Database and Redis

These are already set correctly in the compose file. Only change them if you know you need to.

Option Default in compose file
DB_CONNECTION pgsql
DB_HOST, DB_PORT investbrain-pgsql, 5432
DB_DATABASE, DB_USERNAME, DB_PASSWORD investbrain
REDIS_HOST investbrain-redis

Changing the port

The web port is set by the ports mapping of the app service. To serve on port 8080 instead of 8000, change:

yaml
    ports:
      - 8080:80

and update APP_URL to match, then run docker compose up -d.

Storing data in a host folder

By default storage lives in a named Docker volume. To keep it in a folder on the host instead (handy for backups), swap the volume line in the app service for a bind mount, as shown in the comments of the compose file:

yaml
    volumes:
      - /path/to/storage:/var/app/storage

The container will attempt to correct the folder's permissions on startup.

Hardening

The default compose file is designed to get you running quickly. Before exposing Investbrain to the internet:

  • Change the database password (see step 2 of Installation).
  • Serve over HTTPS through a reverse proxy (below).
  • Turn off registration if you don't want strangers creating accounts.

Running behind a reverse proxy (HTTPS)

Investbrain serves plain HTTP on port 80 inside the container. To use HTTPS and a domain name, put a reverse proxy such as Caddy, Nginx, Traefik, or Nginx Proxy Manager in front of it.

Your proxy must:

  1. Forward the original Host header.
  2. Send X-Forwarded-Proto: https for HTTPS requests. Investbrain uses it to know the request was secure and to build https:// links. Only send this header when the client really connected over HTTPS.

Then set in Investbrain:

yaml
      APP_URL: "https://investbrain.home"
      ASSET_URL: "https://investbrain.home"

MCP and OAuth requirements

The MCP server uses OAuth so AI assistants can connect without a pasted key. For that to work:

  • Use a public HTTPS address for hosted assistants. Claude (web, desktop, and mobile) and ChatGPT connect from their providers' servers, so https://your-host/mcp must be reachable from the internet with a valid certificate. Local assistants such as Claude Code, Cursor, and VS Code can use http://localhost:8000/mcp.
  • Set APP_URL to that public address and make sure your proxy forwards Host and X-Forwarded-Proto (see above). The OAuth discovery metadata tells clients where to send users to sign in. If it points at an internal or http:// address, authorization fails.
  • Keep the storage volume. The OAuth signing keys are created on first start and stored in storage. If they're lost, every API token and authorized assistant stops working and users have to reconnect.

You can check the metadata from any machine:

bash
curl https://investbrain.home/.well-known/oauth-authorization-server

Every URL in the response should start with your public HTTPS address.

Turning off the MCP server

The MCP server is on by default. If you don't want AI assistants to be able to connect to your instance, turn it off:

yaml
      MCP_SERVER_ENABLED: false

Then apply the change.

Market data providers

Investbrain gets prices, fundamentals, dividends, and splits from a market data provider.

Provider MARKET_DATA_PROVIDER value API key needed
Yahoo Finance yahoo No
Twelve Data twelvedata TWELVEDATA_API_SECRET
Finnhub finnhub FINNHUB_API_KEY
Alpaca alpaca ALPACA_API_KEY, ALPACA_API_SECRET
Alpha Vantage alphavantage ALPHAVANTAGE_API_KEY

Yahoo Finance is the default and needs no key. Not every provider supplies every field (for example fundamentals or dividend history), and free tiers often have tight rate limits.

Fallback

List several providers, separated by commas, and Investbrain tries them in order until one succeeds:

yaml
      MARKET_DATA_PROVIDER: "yahoo,finnhub,alphavantage"
      FINNHUB_API_KEY: "..."
      ALPHAVANTAGE_API_KEY: "..."

Here Yahoo Finance is tried first, then Finnhub if Yahoo fails, then Alpha Vantage.

Custom providers

You can add support for another data source by writing a provider class. See Developing market data providers for the interface, a complete example, testing, and how to contribute it. Pull requests for new providers are welcome.

Monitoring market data providers

Open Provider Health from the user menu. For the last 24 hours, 7 days, or 30 days it shows:

  • Total calls, success rate, how often a fallback provider was used, and average response time
  • A chart of calls and failures over time
  • A breakdown per provider and method, with the last failure
  • The most recent failures with the symbol and error message

Use it to spot a provider that's failing or rate limiting you. Old failure records are cleaned up automatically.

Provider Health is only shown to the first account registered on your instance.

To give another account access to provider health, set the user's admin flag in the database:

bash
docker exec -it investbrain-pgsql psql -U investbrain -d investbrain \
  -c "UPDATE users SET admin = true WHERE email = 'someone@example.com';"

If the admin account was deleted and no admin is left, this command makes the oldest remaining account the admin:

bash
docker exec -it investbrain-app php artisan fix:admin

Currency

Investbrain converts between currencies using daily exchange rates from the Frankfurter service, refreshed once per day.

Values are stored in each security's trading currency and also converted into a single base currency (BASE_CURRENCY, default USD). Each user then picks their own display currency, so you don't need to change the base currency for users who prefer euros, pounds, or anything else.

If you do want a different base currency, set BASE_CURRENCY before adding any data. Changing it later leaves previously stored values converted with the old base currency. You generally shouldn't adjust this.

To add a currency that is not in the seeded list (for example PLN), see Custom currencies.

AI chat

To turn on the AI chat assistant:

yaml
      AI_CHAT_ENABLED: true
      CHAT_PROVIDER: anthropic
      ANTHROPIC_API_KEY: "sk-ant-..."
      # CHAT_MODEL: "..."  # optional, defaults to the provider's default model

Swap in the provider and matching key you want to use (see the AI chat options).

Ollama and other OpenAI-compatible servers

yaml
      AI_CHAT_ENABLED: true
      CHAT_PROVIDER: ollama
      OLLAMA_BASE_URL: "http://host.docker.internal:11434"
      CHAT_MODEL: "llama3.1"

Remember that localhost inside the container refers to the container itself. Use your host's LAN address, host.docker.internal (Docker Desktop, or Linux with an extra_hosts: ["host.docker.internal:host-gateway"] entry), or the service name if Ollama runs in the same compose project.

Questions and portfolio details are sent to the provider you configure. Choose a provider whose data policy you're comfortable with, or run a local model.

Social login

Users can sign in with GitHub, Google, Facebook, LinkedIn, or your own single sign-on provider (OpenID Connect) once you register an OAuth app with each provider.

  1. Create an OAuth app (sometimes called a client or application) in the provider's developer console:

    • GitHub: Settings > Developer settings > OAuth Apps
    • Google: Google Cloud Console > APIs & Services > Credentials
    • Facebook: Meta for Developers > My Apps
    • LinkedIn: LinkedIn Developers > My apps (enable Sign In with LinkedIn using OpenID Connect)
  2. Set the authorized callback (redirect) URL to:

    code
    https://<your-investbrain-host>/auth/<provider>/callback
    

    where <provider> is github, google, facebook, linkedin-openid, or oidc. It must match exactly, including http vs https and any port.

  3. Add the credentials and enable the provider:

    yaml
          ENABLED_LOGIN_PROVIDERS: "github,google"
          GITHUB_CLIENT_ID: "..."
          GITHUB_CLIENT_SECRET: "..."
          GOOGLE_CLIENT_ID: "..."
          GOOGLE_CLIENT_SECRET: "..."
    
  4. Apply the change.

Login with ... buttons appear on the login page, and users can link accounts from Connections (see Social logins).

When someone signs in with a provider using an email that already belongs to an Investbrain account, Investbrain emails a verification link before linking them, so email must be working for that case.

By default, when someone signs in with a provider and no account has their email, Investbrain creates an account for them. This works independently of REGISTRATION_ENABLED, so you can turn off the registration form and still let your providers create accounts. To only allow people who already have an Investbrain account, set SSO_AUTO_PROVISION: false; anyone else is sent back to the login page and no account is created.

OpenID Connect (SSO)

If you run your own identity provider, such as Authelia, Authentik, or Keycloak, users can sign in with it through OpenID Connect. Set ENABLED_LOGIN_PROVIDERS: "oidc" plus the OIDC_* options. See Single Sign-On (OIDC) for what to configure in Investbrain and step-by-step settings for each of those providers.

Email

Out of the box, MAIL_MAILER is log, which means emails are written to storage/logs/laravel.log instead of being sent. Investbrain sends email for:

  • Password reset links
  • Portfolio sharing invitations (including the link new users need to set a password)
  • Social login verification links
  • Import success and failure notices
  • Email address verification

To send real email, configure an SMTP server:

yaml
      MAIL_MAILER: smtp
      MAIL_HOST: smtp.example.com
      MAIL_PORT: 587
      MAIL_USERNAME: "investbrain@example.com"
      MAIL_PASSWORD: "..."
      MAIL_ENCRYPTION: tls
      MAIL_FROM_ADDRESS: "investbrain@example.com"
      MAIL_FROM_NAME: "Investbrain"

Emails are sent by the background queue workers, which run inside the app container automatically.

Updating

bash
docker compose pull
docker compose up -d

This downloads the latest images and recreates the containers. Database migrations run automatically on startup. Your data is kept in the volumes.

It's a good idea to back up before updating. The running version is printed at the top of the app container's log on startup.

Don't change the major version of the postgres image (for example from 15 to 16) on an existing database volume. PostgreSQL can't read data files from a different major version. To upgrade PostgreSQL, dump the database, start a fresh volume with the new version, and restore.

Command line utilities

Investbrain includes several command line utilities for maintenance. They can make large, irreversible changes, so back up first. Run them inside the app container:

bash
docker exec -it investbrain-app php artisan <command>

Add --help to any command to see its options.

Command Description
refresh:market-data Refresh prices for all open positions. --force ignores the refresh interval, --user=<id> limits it to one user's holdings.
refresh:dividend-data Refresh dividend data and recalculate dividends earned. --force refreshes every holding, --user=<id> limits it to one user.
refresh:split-data Refresh split data and create transactions for new splits. --force refreshes every holding.
refresh:currency-data Download the latest exchange rates.
capture:daily-change Capture today's snapshot for every portfolio now.
sync:daily-change <portfolio_id> Rebuild a portfolio's entire daily history from market data. Useful for filling gaps in charts. Resource intensive. --force skips the confirmation.
sync:holdings Recalculate every holding from its transactions and dividends. --user=<id> limits it to one user.
fix:admin Make the oldest account the admin when no admin is left, for example after the admin account was deleted. Does nothing if an admin already exists. Only runs when SELF_HOSTED is true (the default).
fix:cost-basis-for-sales Recalculate the cost basis of sell transactions. --portfolio=<id> or --user=<id> limits the scope.

Find a portfolio's ID in the address bar of its page (/portfolio/<id>).

For more help, see Troubleshooting.

Edit this page Last updated November 7, 2026