Skip to content

Commit

Permalink
docs: 📝 improve operator example file configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignazio Bovo committed Dec 15, 2023
1 parent 3dc596a commit a5d4c46
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 3 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,17 @@
Orion is a backed node powering [Atlas](https://github.com/Joystream/atlas).
The project is using [Subsquid framework](https://docs.subsquid.io/) and is based on [squid-substrate-template](https://github.com/subsquid/squid-substrate-template).

## Operator Quickstart
This quickstart guide will assume that you have
1. clone the directory using
```sh
git clone https://github.com/Joystream/orion.git
```
2. cd into the orion developer examples
```sh
cd docs/operator-guide/examples
```
3.

## [Developer guide](docs/developer-guide/index.md)
## [Operator guide](docs/operator-guide.md)
40 changes: 39 additions & 1 deletion docs/operator-guide/examples/.env
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,28 @@ DEV_DISABLE_SAME_SITE=true

# The name of Your gateway (pick a unique one!)
APP_NAME=<YOUR GATEWAY NAME>

# Whether videos with no category assigned should be visible on the gateway
SUPPORT_NO_CATEGORY_VIDEOS=<true/false>

# Whether the gateway should support all newly created video categories
# by default.
SUPPORT_NEW_CATEGORIES=<true/false>

# Default value of the "kill switch". If set to true, it will force the
# Atlas to start in a "maintenance mode", before the value of the kill
# switch is changed via the operator API.
KILL_SWITCH_ON=<true/false>

# The number of seconds that need to pass before a video view from the
# same user is counted again.
VIDEO_VIEW_PER_USER_TIME_LIMIT=300

# A secret string that will be used when authenticating as a Gateway operator.
# It's recommended to generate a random string of at least 16 characters.
# For example: `openssl rand -base64 18`
OPERATOR_SECRET=<SECURELY RANDOM SECRET>

# Weights used for calclating the relevance score of a video.
# The relevance score affects the order in which videos are displayed
# on the homepage of Atlas.
Expand All @@ -72,12 +78,15 @@ OPERATOR_SECRET=<SECURELY RANDOM SECRET>
# The fifth value is a list of two values:
# - joystreamCreationWeight: how much Video.createdAt date affects the `newness` score
# - ytCreationWeight: how much Video.publishedBeforeJoystream affects the `newness` score
# The sixth value is the "channel_weight".
# The relevance score is calculated as follows:
# ```
# (
# newness * newness_weight +
# views * views_weight +
# comments * comments_weight +
# reactions * reactions_weight
# ) * channel_weight
# ```
# Where newness is:
# ```
Expand All @@ -86,42 +95,53 @@ OPERATOR_SECRET=<SECURELY RANDOM SECRET>
# (days since Video.publishedBeforeJoystream * ytCreationWeight)
# ) / (joystreamCreationWeight + ytCreationWeight)
# ```
RELEVANCE_WEIGHTS="[1, 0.03, 0.3, 0.5, [7,3]]"
RELEVANCE_WEIGHTS="[1, 0.03, 0.3, 0.5, [7,3], 1]"

# After how many new video views, the relevance score of a video should
# be recalculated.
VIDEO_RELEVANCE_VIEWS_TICK=10

# Maximum number of entities that can be cached in Orion processor's memory.
# If the Orion processor service is running out of memory, try decreasing
# this value.
MAX_CACHED_ENTITIES=1000

# A secret string used to generate a private key for signing the attestation
# that certain channels and videos were created throguh Your gateway.
# It's recommended to generate a random string of at least 16 characters.
# For example: `openssl rand -base64 18`
APP_PRIVATE_KEY=<SECURELY RANDOM SECRET>

# After how many minutes does the session expire in case of user inactivity.
# Once the session expires, the user will need to re-authenticate.
SESSION_EXPIRY_AFTER_INACTIVITY_MINUTES=60

# After how many hours does the session expire regardless of user activity.
SESSION_MAX_DURATION_HOURS=720

# The route in Atlas used for the purpose of user e-mail confirmation.
# CURRENTLY NOT USED
EMAIL_CONFIRMATION_ROUTE=NOT_USED

# The number of hours after which the e-mail confirmation link expires.
EMAIL_CONFIRMATION_TOKEN_EXPIRY_TIME_HOURS=24

# How many e-mail confirmation links can be sent to a user within
# `EMAIL_CONFIRMATION_TOKEN_EXPIRY_TIME_HOURS` (to prevent spamming)
EMAIL_CONFIRMATION_TOKEN_RATE_LIMIT=5

# How many seconds have to pass since the timestamp included in a signed message
# that proves the ownership of a Joystream account/address, before the message
# is considered expired.
ACCOUNT_OWNERSHIP_PROOF_EXPIRY_TIME_SECONDS=300 # 5 minutes

# A secret string used to generate a private key for the purpose of signing cookies,
# to ensure that the cookies sent by the client application (like Atlas) have been
# indeed set by your instance of Orion and have not been tampered with.
# It's recommended to generate a random string of at least 16 characters.
# For example: `openssl rand -base64 18`
COOKIE_SECRET=<SECURELY RANDOM SECRET>

# max number of attempts to deliver email notification
EMAIL_NOTIFICATION_DELIVERY_MAX_ATTEMPTS=5

Expand All @@ -133,5 +153,23 @@ SENDGRID_FROM_EMAIL=<NO-REPLY EMAIL ADDRESS>
# Notification emails storage links
# Online path which contains the icons and logo to display in the notification e-mails
APP_ASSET_STORAGE=<LINK_TO_STORAGE_ASSETS>

# Name of the application link displayed in the notification e-mail footer
APP_NAME_ALT=<ALTERNATIVE_APP_NAME>


# ==================================================================================
# ============================= ARCHIVE CONFIGURATION ==============================
# ==================================================================================

# postgres database port used by the archive
ARCHIVE_DB_PORT=12345

# Port that is used by the processor to fetch batches of block
GATEWAY_PORT=8888

# alternatively you can point to your own joystream rpc node if you have one
WS_SOURCE=wss://rpc.joystream.org:9944

# port exposed by the explorer
EXPLORER_PORT=4444
6 changes: 6 additions & 0 deletions docs/operator-guide/examples/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ query.{$GATEWAY_ROOT_DOMAIN} {
reverse_proxy orion-graphql-api:{$GRAPHQL_API_PORT}
}

# # Optional: uncomment if you deployed the archive
# archive.{$GATEWAY_ROOT_DOMAIN} {
# reverse_proxy orion-graphql-api:{$GATEWAY_PORT}
# }


{$GATEWAY_ROOT_DOMAIN} {
root * /srv/atlas
file_server
Expand Down
74 changes: 73 additions & 1 deletion docs/operator-guide/examples/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- ./db/export:/squid/db/export
command: >
sh -c "npx squid-typeorm-migration apply && \
node lib/processor.js"
node lib/processor.js"
ports:
- '127.0.0.1:${PROCESSOR_PROMETHEUS_PORT}:${PROCESSOR_PROMETHEUS_PORT}'
# Orion GraphQL API
Expand Down Expand Up @@ -84,6 +84,78 @@ services:
- ./caddy/data:/data
- ./caddy/config:/config

archive_db:
container_name: orion_archive_db
hostname: orion_archive_db
image: postgres:14 # CockroachDB cluster might be a better fit for production deployment
restart: unless-stopped
volumes:
- orion_archive_db_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: squid-archive
ports:
- '127.0.0.1:${ARCHIVE_DB_PORT}:${ARCHIVE_DB_PORT}'
- '[::1]:${ARCHIVE_DB_PORT}:${ARCHIVE_DB_PORT}'
command: ['postgres', '-c', 'log_statement=all', '-p', '${DB_PORT}']

ingest:
container_name: orion_archive_ingest
depends_on:
- archive_db
restart: unless-stopped
image: subsquid/substrate-ingest:firesquid
command: [
'-e',
'${WS_SOURCE}',
'-c',
'20', # allow up to 20 pending requests for the above endpoint (default is 5)
# "--start-block", "1000000", # uncomment to specify a non-zero start block
'--out',
'postgres://postgres:postgres@orion_archive_db:${DB_PORT}/squid-archive',
]

gateway:
container_name: orion_archive_gateway
hostname: orion_archive_gateway
depends_on:
- archive_db
restart: unless-stopped
image: subsquid/substrate-gateway:firesquid
environment:
DATABASE_MAX_CONNECTIONS: 5
RUST_LOG: 'actix_web=info,actix_server=info'
command: [
'--database-url',
'postgres://postgres:postgres@orion_archive_db:${DB_PORT}/squid-archive',
# "--evm-support" # uncomment for chains with Frontier EVM pallet
# (e.g. Moonbeam/Moonriver or Astar/Shiden)
]
ports:
- '127.0.0.1:${GATEWAY_PORT}:8000'
- '[::1]:${GATEWAY_PORT}:8000'

# Explorer service is optional.
# It provides rich GraphQL API for querying archived data.
# Many developers find it very useful for exploration and debugging.
explorer:
container_name: orion_archive_explorer
hostname: orion_archive_explorer
restart: unless-stopped
image: subsquid/substrate-explorer:firesquid
environment:
DB_TYPE: postgres # set to `cockroach` for Cockroach DB
DB_HOST: archive_db
DB_PORT: '12345'
DB_NAME: 'squid-archive'
DB_USER: 'postgres'
DB_PASS: 'postgres'
ports:
- '${EXPLORER_PORT}:3000'

volumes:
orion_archive_db_data:
driver: local
orion-db-data:
driver: local
6 changes: 5 additions & 1 deletion docs/operator-guide/tutorials/deploying-orion.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ You will also need a sendgrid account with an api key in order to have email not
```

That's it! Your gateway should now be available under `https://mygateway.com`!
If you kept the Auth API playground enabled in your `.env` (`OPENAPI_PLAYGROUND=true`), you can also use `https://auth.mygateway.com/playground` to perform the Operator authentication (as described in _[Local testing](./local-testing.md#authentication)_ tutorial) and then execute Operator queries and mutations through `https://query.mygateway.com/graphql`.
If you kept the Auth API playground enabled in your `.env` (`OPENAPI_PLAYGROUND=true`), you can also use `https://auth.mygateway.com/playground` to perform the Operator authentication (as described in _[Local testing](./local-testing.md#authentication)_ tutorial) and then execute Operator queries and mutations through `https://query.mygateway.com/graphql`.
### Email notification setup
If your orion version is more recent or equal than `3.2.0` then you have the opportunity to allow users to be notified via email for various events. See [here](./email-notifications.md) for a guide on how to setup the email
scheduling chron job

0 comments on commit a5d4c46

Please sign in to comment.