Skip to content

Latest commit

 

History

History
153 lines (113 loc) · 5.35 KB

SELFHOSTING.md

File metadata and controls

153 lines (113 loc) · 5.35 KB

Self hosting

Development instructions

Setup

  1. Pre-requisite

    • Install asdf
    • Install PostgreSQL Server
    • Fork and clone branch master of this Mono repo.
    • Register application on Unsplash which is used as an Image Catalog.
  2. Create a PostgreSQL database and replace the configurated values in core/config/dev.exs with your own:

    # Configure your database
    config :core, Core.Repo,
    username: "postgres",
    password: "postgres",
    database: "self_dev",
  3. Install tools:

    $ asdf plugin-add erlang
    $ asdf plugin-add elixir
    $ asdf plugin-add nodejs
    
    $ asdf install

    See .tool-versions for the exact versions that will be installed

  4. Setup:

    $ cd core
    $ mix setup
  5. Build Core (from core folder):

    $ BUNDLE=self mix compile
  6. Run Core locally (from core folder):

    $ BUNDLE=self mix phx.server
  7. Go to browser

    The Core app is running at: http://localhost:4000

Customizing

Branding

Menu items

  • In items.ex you will find all the menu items. Add custom items when required.

Core supports the following page layouts:

  • Stripped: minimalistic page without menu
  • Website: menu at the top
  • Workspace: menu on the left

Change the menus here:

Rate limiters

To prevent users from exhausting resources on external services, Core uses rate limiters. The local configuration of rate limiters can be found in core/config/dev.exs:

config :core, :rate,
  prune_interval: 5 * 1000,
  quotas: [
    [service: :azure_blob, limit: 1, unit: :call, window: :second, scope: :local],
    [service: :azure_blob, limit: 100, unit: :byte, window: :second, scope: :local]
  ]

.. and the production configuration can be found in core/config/config.exs:

config :core, :rate,
  prune_interval: 60 * 60 * 1000,
  quotas: [
    [service: :azure_blob, limit: 1000, unit: :call, window: :minute, scope: :local],
    [service: :azure_blob, limit: 10_000_000, unit: :byte, window: :day, scope: :local],
    [service: :azure_blob, limit: 1_000_000_000, unit: :byte, window: :day, scope: :global]
  ]

Release instructions

  1. Create a Docker image
$ cd core
$ docker build  --build-arg VERSION=1.0.0 --build-arg BUNDLE=self . -t self:latest
$ docker image save self -o self.zip
  1. Run the Docker image

Required environment variables:

Variable Description Example value
APP_NAME Core app name "Self"
APP_DOMAIN domain where the Core app is hosted "my.server.com"
APP_MAIL_DOMAIN Domain of your email (after the @) "self.com"
APP_ADMINS String with space seperated email adresses of the system admins, supports wildcards "[email protected] [email protected]"
DB_USER Username <my-username>
DB_PASS Password <my-password>
DB_HOST Hostname "domain.where.database.lives"
DB_NAME Name of the database in the PostgreSQL "self_prod"
SECRET_KEY_BASE 64-bit sequence of random characters <long-sequence-of-characters>
STATIC_PATH Path to folder where uploaded files can be stored "/tmp"
UNSPLASH_ACCESS_KEY Application access key registered on Unsplash (Image Catalog) "hcejpnHRuFWL-fKXLYqhGBt1Dz0_tTjeNifgD01VkGE"
UNSPLASH_APP_NAME Application name registered on Unsplash (Image Catalog) "Self"
STORAGE_SERVICES Comma seperated list of storage services "yoda, aws, azure"

Optional environment variables:

Variable Description Example value
LOG_LEVEL Console log level "debug", "info", "warn", "error"
SENTRY_DSN app monitoring https://1234febac1234365cfe2d1fad616845b@o1234721120555008.ingest.sentry.io/1235721234883520"
GOOGLE_SIGN_IN_CLIENT_ID "123466465353-mui7en8912341rpn6qaevb89rd01234.apps.googleusercontent.com"
GOOGLE_SIGN_IN_CLIENT_SECRET "Q_lSWMy1234nPhxof1234Xyc"
SURFCONEXT_SITE SURFconext site "https://connect.test.surfconext.nl"
SURFCONEXT_CLIENT_ID SURFconext client ID "self.com"
SURFCONEXT_CLIENT_SECRET SURFconext client secret "12343HieOjb1234hcBpL"
STORAGE_S3_PREFIX Prefix for S3 builtin storage objects. Without this variable "builtin" storage service will default to local filesystem "storage"
CONTENT_S3_PREFIX Prefix for S3 content objects "content"
FELDSPAR_S3_PREFIX Prefix for S3 feldspar objects "feldspar"
PUBLIC_S3_URL Public accessable url of an S3 service "https://self-public.s3.eu-central-1.amazonaws.com"
PUBLIC_S3_BUCKET Name of the bucket on the S3 service "self-prod"
DIST_HOSTS Comma seperated list of hosts in the cluster, see: OTP Distribution "one, two"