### Description Improved grammar, structure, and tone of the `docs/self_hosting.md` file for better clarity and consistency. Changes include fixing typos, rewording vague instructions, improving formatting, and aligning with the overall documentation tone. ### Checks - [x] Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info) - [x] Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title. ### Other notes This PR does not add any quotes, languages, themes, or layouts. --- Closes # (none)
6.6 KiB
Monkeytype Self Hosting
Table of contents
Prerequisites
- you need to have
dockeranddocker-compose-plugininstalled. Follow the docker documentation on how to do this.
Quickstart
- create a new directory (e.g.
monkeytype) and navigate into it. - download the docker-compose.yml file.
- create an
.envfile, you can copy the content from the example.env. - download the backend-configuration.json
- run
docker compose up -d - after the command exits successfully you can access http://localhost:8080
Account System
By default, user sign-up and login are disabled. To enable this, you'll need to set up a Firebase project.
Stop the running docker containers using docker compose down before making any changes.
Setup Firebase
-
create a Firebase account
-
create a new Firebase project.
- name "monkeytype"
- uncheck "enable google analytics"
-
enable authentication
- open the firebase console and open your project
- go to
Authentication > Sign-in method - enable
Email/Passwordand save
-
generate service account
- go to your project settings by clicking the
⚙icon in the sidebar, thenProject settings - navigate to the
Service accountstab - click
Generate new private keyto download the.jsonfile. - save it as
serviceAccountKey.json - update
docker-compose.ymland uncomment the volume block in themonkeytype-backendcontainer to mount the Firebase service account:#uncomment to enable the account system, check the SELF_HOSTING.md file - type: bind source: ./serviceAccountKey.json target: /app/backend/src/credentials/serviceAccountKey.json read_only: true
- go to your project settings by clicking the
-
update the
.envfile- open the firebase console and open your project
- open the project settings by clicking the
⚙icon on the sidebar andProject settings - if your project has no apps yet, create a new Web app (
</>icon)- nickname
monkeytype - uncheck
set up firebase hosting - click
Register app
- nickname
- select your app and select
ConfigforSDK setup and configuration - it will display something like this:
const firebaseConfig = { apiKey: "AAAAAAAA", authDomain: "monkeytype-00000.firebaseapp.com", projectId: "monkeytype-00000", storageBucket: "monkeytype-00000.appspot.com", messagingSenderId: "90000000000", appId: "1:90000000000:web:000000000000" }; - update the
.envfile with the values above:FIREBASE_APIKEY=AAAAAAAA FIREBASE_AUTHDOMAIN=monkeytype-00000.firebaseapp.com FIREBASE_PROJECTID=monkeytype-00000 FIREBASE_STORAGEBUCKET=monkeytype-00000.appspot.com FIREBASE_MESSAGINGSENDERID=90000000000 FIREBASE_APPID=1:90000000000:web:000000000000
Update backend configuration
- update the
backend-configuration.jsonfile and add/modify{ "users": { "signUp": true, "profiles": { "enabled": true } } }
Setup Recaptcha
- create a new recaptcha token
- label:
monkeytype - type: v2
- domain: the domain of the frontend
- label:
- update the
.envfile with the site key from the previous stepRECAPTCHA_SITE_KEY="your site key" RECAPTCHA_SECRET="your secret key"
If you host privately you can use these defaults:
RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
RECAPTCHA_SECRET=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
Setup email (optional)
To enable emails for password reset and email verification update the following config in .env file:
# email server config
# uncomment below if you want to send emails for e.g. password reset
EMAIL_HOST=mail.myserver # your mailserver domain
EMAIL_USER=mailuser # username to authenticate with your mailserver
EMAIL_PASS=mailpass # password for the user
EMAIL_PORT=465 # port, likely 465 or 587
EMAIL_FROM="Support <noreply@myserver>"
Enable daily leaderboards
To enable daily leaderboards update the backend-configuration.json file and add/modify
{
"dailyLeaderboards": {
"enabled": true,
"maxResults": 250,
"leaderboardExpirationTimeInDays": 1,
"validModeRules": [
{
"language": "english",
"mode": "time",
"mode2": "15"
},
{
"language": "english",
"mode": "time",
"mode2": "60"
}
]
}
}
- language is one of the supported language
- mode can be
timeorwords - mode2 can be
15,30,60or120if you pickedmode=timeor10,25,50or100if you pickedmode=words.
Configuration files
env file
All settings are described in the example.env file.
serviceAccountKey.json
Contains your firebase config, only needed if you want to allow users to signup.
backend-configuration.json
Configuration of the backend. Check the default configuration for possible values.
Note
Configuration changes are applied only on container startup. You must restart the container for your updates to take effect.