Skip to content

Setup Instructions

Andrew Brown edited this page Feb 16, 2023 · 14 revisions

Notebook.ai is a complex platform that's built to be somewhat modular, allowing you to set up just the features you want to use. For these setup instructions, I'll break down the setup into two separate paths:

  • Minimal setup (no third-party integrations, just Notebook.ai running locally)
  • Full setup (all integrations and configuration to match https://www.notebook.ai)

Minimal setup

  1. Make sure you have Ruby installed. Make sure your Ruby version matches the version specified in .ruby-version.

    Tip: Using a Ruby version manager like RVM makes it easy to install, manage, and flip between specific Ruby versions.

  2. Install the necessary native libraries for your system. These are the libraries I use on Ubuntu; you may use a different package manager or have different package names on other systems.

sudo apt-get update
sudo apt-get install imagemagick libmagickwand-dev libpq-dev libsqlite3-dev nodejs npm
  1. Clone the notebook repo and then cd into it.
git clone git@github.com:indentlabs/notebook.git
cd notebook
  1. Install the required gems. This will also install Rails.
bundle install
  1. By default, Notebook.ai uses SQLite for development environments and Postgresql for production environments. If you wish to use a different database for your desired environment, this is the step where you would install it. You can configure the app to use it in config/database.yml.

  2. Create and prepare your database

rake db:create
rake db:migrate
rake billing_plans:initialize_defaults
rake data_migrations:create_default_billing_plans
rake db:seed
  1. Build and prepare Javascript assets with yarn. The webpack-dev-server will continue to run and automatically recompile your assets as you change them.
yarn install
./bin/webpack-dev-server

Tip: If you run into any issues with yarn, make sure you have the latest nodejs and npm installed. This SO answer also helps me with permission issues on an OOTB install on Ubuntu.

  1. You also want to make sure you're running a redis server, so Notebook.ai can queue and complete tasks in the background.
sudo apt-get install redis
  1. You can now run the server with the following command (in another terminal, if you leave webpack-dev-server running):
bundle exec rails server

Full setup (work-in-progress)

All of the above, plus...

  1. Set the following environment variables
RAILS_ENV=production
RACK_ENV=production
RAILS_SERVE_STATIC_FILES=enabled
  1. Precompile your assets
bundle exec rake assets:precompile
  1. To enable background jobs (saving document revisions, linking content together, etc), you'll want to install and make sure you're running sidekiq. This will process all queues by default. You can also see a list of all queues in config/sidekiq.yml and run specific ones with the -q <queue_name> flag.
bundle exec sidekiq -C config/sidekiq.yml
  1. To enable document analysis, you'll need an IBM Watson account with billing set up. Add your IBM API key to the environment variable WATSON_API_KEY. Billing will scale based on the number of document words analyzed. You will also need sidekiq running for analysis jobs to process.

  2. To enable image uploads, you'll need an AWS account with S3 set up and configured for read/write access to a bucket. Provide your credentials via the following environment variables:

  AWS_REGION:                 us-east-1
  AWS_ACCESS_KEY_ID:          your-access-key-id-here
  AWS_SECRET_ACCESS_KEY:      your-secret-access-key-here
  S3_BUCKET_NAME:             your-bucket-name-here

You can specify alternative storage providers in config/storage.yml, but they may need some extra configuration to work as expected.

  1. To configure redis, set up an accessible redis instance and set the REDIS_URL environment variable to its connection string.

  2. To enable email sending (password resets, collaboration invites, etc), you'll want to set up a billable SendGrid account and provide authentication information through the following environment variables:

  SENDGRID_DOMAIN:            your-sendgrid-domain
  SENDGRID_USERNAME:          your-sendgrid-username
  SENDGRID_PASSWORD:          your-sendgrid-password

You'll need to specify your authorized SendGrid senders in config/initializers/devise.rb (for password resets) and each of the mailers in app/mailers (for functional emails).

  1. To enable Paypal payments, you'll want to provide your Paypal API credentials in the following environment variables:
  PAYPAL_CLIENT_ID:           your-paypal-client-id
  PAYPAL_SECRET:              your-paypal-secret-key
  1. To enable Stripe payments, you'll want to provide your live Stripe API credentials in the following environment variables:
  STRIPE_API_KEY:             your-stripe-secret-key
  STRIPE_PUBLISHABLE_KEY:     your-stripe-public-key
  1. To enable New Relic & error reporting, provide your license key in the NEW_RELIC_LICENSE_KEY environment variable. You can optionally specify a log destination (such as stdout) in the environment variable NEW_RELIC_LOG.

  2. To enable database snapshots, recovery, and fallback,

  3. To enable Slack integration,

  4. To scale, I use the following architecture (set as ENV variables):

  WEB_CONCURRENCY=2
  RAILS_MAX_THREADS=16
  MALLOC_ARENA_MAX=2
  DB_POOL=25
  RUBY_GC_HEAP_GROWTH_FACTOR=1.03
Clone this wiki locally