Skip to content

Commit

Permalink
Merge pull request #506 from eyra/self-hosting
Browse files Browse the repository at this point in the history
Self hosting
  • Loading branch information
mellelieuwes authored Dec 5, 2023
2 parents d398291 + 707b1f9 commit 82ba3c5
Show file tree
Hide file tree
Showing 54 changed files with 309 additions and 2,207 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
workflow_dispatch:
inputs:
bundle:
description: "Bundle ID (link / next etc.)"
description: "Bundle ID (next)"
required: true
default: "link"
default: "next"
jobs:
tagged-release:
runs-on: ubuntu-20.04
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@ Project implementing a SaaS platform based on interlinked modules called Systems
* Lab
* Questionnaire
* Pool
* Data Donation
* ..

### Bundles

* Next

Primary bundle with all features available except Link specific features.
Next is hosted on: https://eyra.co
Primary bundle with all features available. Next is configured and maintained by Eyra and hosted on: https://eyra.co

* Link
* Self

Customizable bundle that can be used to run Core on one of your own servers.
See [SELFHOSTING.md](SELFHOSTING.md) for detailed instructions.

Secundary bundle with only Panl specific features.
Link is hosted on: https://researchpanl.eu

## Banking Proxy

Expand Down
156 changes: 156 additions & 0 deletions SELFHOSTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Self hosting

## Development instructions

### Setup

0. Pre-requisite

* Install [asdf](https://asdf-vm.com)
* Install [PostgreSQL Server](https://www.postgresql.org)
* Fork and clone branch `master` of this Mono repo.
* Register application on [Unsplash](https://unsplash.com/) which is used as an Image Catalog.

1. Create a PostgreSQL database and replace the configurated values in `core/config/dev.exs` with your own:

```Elixir
# Configure your database
config :core, Core.Repo,
username: "postgres",
password: "postgres",
database: "self_dev",
```

2. Install tools:

```sh
$ 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

3. Install dependencies:
```sh
$ cd core
$ make install
```

4. Build Core (from core folder):

```sh
$ BUNDLE=self make build
```

5. Run database migrations (from core folder)

```sh
$ mix ecto.migrate
```

6. Run Core locally (from core folder):

```sh
$ BUNDLE=self make run
```

8. Go to browser

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


## Customizing

### Branding

* Replace [self.svg](core/assets/static/images/icons/self.svg) and [self_wide.svg](core/assets/static/images/icons/self_wide.svg) with your icons of choice.
* Change [footer.ex](core/lib/core_web/ui/footer.ex) to format the platform footer or remove it completely

### Menu items

* In [items.ex](core/bundles/self/lib/menu/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:
* [Stripped](core/bundles/self/lib/layouts/stripped/menu_builder.ex)
* [Website](core/bundles/self/lib/layouts/website/menu_builder.ex)
* [Workspace](core/bundles/self/lib/layouts/workspace/menu_builder.ex)


### 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`:

```Elixir
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`:

```Elixir
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

```sh
$ cd core
$ docker build --build-arg VERSION=1.0.0 --build-arg BUNDLE=self . -t self:latest
$ docker image save self -o self.zip
```

2. 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 | "person1@self.com person2@self.com" |
| 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 | "/home/self/uploads" |
| UNSPLASH_ACCESS_KEY | Application access key registered on [Unsplash](https://unsplash.com/) (Image Catalog) | "hcejpnHRuFWL-fKXLYqhGBt1Dz0_tTjeNifgD01VkGE" |
| UNSPLASH_APP_NAME | Application name registered on [Unsplash](https://unsplash.com/) (Image Catalog) | "Self" |

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" |
| CONTENT_S3_PREFIX | Prefix for S3 content storage | "content" |
| FELDSPAR_S3_PREFIX | Prefix for S3 feldspar storage | "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](https://elixirschool.com/en/lessons/advanced/otp_distribution) | "one, two" |
8 changes: 8 additions & 0 deletions core/assets/static/images/icons/self.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions core/assets/static/images/icons/self_wide.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 82ba3c5

Please sign in to comment.