These instructions aim to give you an exemplary manual on how to host your
lean4game instance such that others can access it via the internet.
This manual will assume that you already have a running Linux server that
uses the apt package manager.
(The steps are analogous for other Linux distributions and their package managers.)
We will use nginx for our server, but any other web server might be applied here. The same logic applies to pm2 as our choice for process management tool.
- Install a
nginxweb server as reverse proxy
sudo apt update
sudo apt install nginx- install
npmfor building JavaScript projects
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
source ~/.bashrc
nvm install node npm- install
pm2to manage processes on the server
sudo npm install pm2 -g- install
tscto compile TypeScript projects on the server
sudo npm install typescript -g- Install
bubblewrapfor secure execution of lean server
sudo apt-get install bubblewrap- install
elanto manage versions of the Lean4 programming language and theorem prover
curl https://elan.lean-lang.org/elan-init.sh -sSf | shThis will install the current version of elan with a default installation of lean and the lake package manager.
- Conclude
elaninstallation by configuring your current shell to it
source $HOME/.elan/envThe next step is to set up a reverse proxy with nginx and to add information concerning domain and SSL certification. As those considerations are quite individual, technical and safety critical, we refer to general instructions on how to set up a reverse proxy using nginx on Ubuntu.
This section will be somewhat similar to what is written in the section about running Lean4Game locally. We diverge here in that we only describe the installation of Lean4Game itself. Before starting, you will need to generate a fine-grained GitHub access token with the following properties:
- Expiration: choose "Custom" and select a day up to 365 days from today. (Note that you will need to update the token after a year)
- Repository access: Public repositories (read-only)
- No further permissions. It should say "0 permissions for none of your repositories" and "0 account permissions"
Save the access token after its generation as you can only see it once, and it is needed for step 3.
- Clone hosted projects via
gitonto server. Important: Please use the HTTPS URL from GitHub, not the SSH URL, to clone the project repositories.
git clone https://github.com/leanprover-community/lean4game.git- Install lean4game dependencies via
npm
cd lean4game
npm install- Set lean4game environment variables in
ecosystem.config.cjsfile. The github access token should have been generated and saved as described in the beginning of this section.
// This is a configuration file for pm2, a production process manager for nodejs
module.exports = {
apps : [{
name : "lean4game",
script : "relay/dist/src/index.js",
env: {
LEAN4GAME_GITHUB_USER: "<to-be-requested-from-admin>",
LEAN4GAME_GITHUB_TOKEN: "<to-be-requested-from-admin>",
RESERVED_DISC_SPACE_MB: <RESERVED_SPACE>,
ISSUE_CONTACT: "<contact_link>",
NODE_ENV: "production",
PORT: <PORT>,
API_PORT: <API_PORT>,
},
}]
}- Build lean4game project via
npm
npm run build- Start Lean4Game through PM2
pm2 start ecosystem.config.cjsHaving done that you should now be able to access your hosted Lean4Game instance via the domain that has been specified during the setup of the nginx server. For more information on how to maintain your established server, please refer to the server maintenance documentation.