Deployment Guide
This guide goes into details on how to compile and deploy Gauss Explorer instance to work with Polygon-Edge. Gauss Explorer has its own documentation, but this guide focuses on simple but detailed step-by-step instructions on how to setup Gauss Explorer instance.
Operating System: Ubuntu Server 20.04 LTS download link with sudo permissions
Server Hardware: 8CPU / 16GB RAM / 50GB HDD (LVM)
Database Server: Dedicated server with 2 CPU / 4GB RAM / 100GB SSD / PostgreSQL 13.4
DB Server
The requirement for following this guide is to have a database server ready, database and db user configured. This guide will not go into details on how to deploy and configure PostgreSQL server. There are plenty of guides on now to do this, for example DigitalOcean Guide
DISCLAIMER
This guide is meant only to help you to get Gauss Explorer up and running on a single instance which is not ideal production setup. For production, you'll probably want to introduce reverse proxy, load balancer, scalability options, etc. into the architecture.
Gauss Explorer Deployment Procedure
Before we start we need to make sure we have all the binaries installed that the Gauss Explorer is dependent on.
Update & upgrade system
Add erlang repos
Add NodeJS repo
Install Rust
Install required version of Erlang
Install required version of Elixir
The version of Elixir must be 1.13
. If we try and install this version from the official repo, the erlang
will update to Erlang/OTP 25
and we do not want that.
Because of this, we need to install the specific precompiled elixir
version from GitHub releases page.
Now we need to properly set up exlixir
system binaries.
Check if elixir
and erlang
are properly installed by running elixir -v
. This should be the output:
WARNING
Erlang/OTP must be version 24
and Elixir
must be version 1.13.*
.
If that is not the case, you will run into issues with compiling Gauss Explorer and/or running it.
Install NodeJS
Install Cargo
Install other dependencies
Optionally install postgresql client to check your db connection
We need to set the environment variables, before we begin with Gauss Explorer compilation. In this guide we'll set only the basic minimum to get it working. Full list of variables that can be set you can find here
Set database connection as environment variable
Now test your DB connection with provided parameters. Since you've provided PG env vars, you should be able to connect to the database only by running:
If the database is configured correctly, you should see a psql prompt:
Otherwise, you might see an error like this:
If this is the case these docs might help you.
DB Connection
Make sure you've sorted out all db connection issues before proceeding to the next part. You'll need to provide superuser privileges to gaussExplorer user.
Now we finally get to start the Gauss Explorer installation.
Clone Gauss Explorer repo
Generate secret key base to protect production build
At the very last line, you should see a long string of random characters.
This should be set as your SECRET_KEY_BASE
environment variable, before the next step.
For example:
Install and start Smart Contract Verification Microservice
nstall and start smart contract verification microservice. You can use docker, build from source, or use cargo directly (example below).
cargo install --git https://github.com/blockscout/blockscout-rs smart-contract-verifier-http
Run the binary as
smart-contract-verifier-http
Set ENV variables in CLI to enable the rust microservice for Blockscout (these can also be set at runtime).
Set production mode
Compile
Cd into clone directory and start compiling
info
If you have deployed previously, remove static assets from the previous build mix phx.digest.clean.
Migrate databases
info
This part will fail if you didn't set up your DB connection properly, you didn't provide, or you've defined wrong parameters at DATABASE_URL environment variable. The database user needs to have superuser privileges.
If you need to drop the database first, run
Install npm dependencies and compile frontend assets
You need to change directory to the folder which contains frontend assets.
Be patient
Compilation of these assets can take a few minutes, and it will display no output. It can look like the process is stuck, but just be patient. When compile process is finished, it should output something like: webpack 5.69.1 compiled with 3 warnings in 104942 ms
Build static assets
For this step you need to return to the root of your Gauss Explorer clone folder.
Generate self-signed certificates
info
You can skip this step if you won't use https
.
In this part we need to set up a system service as we want Gauss Explorer to run in the background and persist after system reboot.
Create service file
Edit service file
Use your favorite linux text editor to edit this file and configure the service.
The contents of the explorer.service file should look like this:
Enable starting service on system boot
Move your Gauss Explorer clone folder to system-wide location
Gauss Explorer service needs to have access to the folder you've cloned from Gauss Explorer repo and compiled all the assets.
Create env vars file which will be used by Gauss Explorer service
info
Use SECRET_KEY_BASE
you've generated in Part 3.
Save the file and exit.
Finally, start Gauss Explorer service
Now all that's left to do is to check if Gauss Explorer service is running. Check service status with:
To check service output:
You can check if there are some new listening ports:
You should get a list of listening ports and on the list there should be something like this:
Gauss Explorer web service runs the port and protocol defined in env file. In this example it runs on 4000
(http).
If everything is ok, you should be able to access the Gauss Explorer web portal with http://<host_ip>:4000
.
For best performance, it is advisable to have a dedicated/local polygon-edge
full archive non-validator node that will be used exclusively for Gauss Explorer queries.
The json-rpc
API of this node, doesn't need to be exposed publicly, as Gauss Explorer runs all queries from the backend.
We've just deployed a single Gauss Explorer instance, which works fine, but for production you should consider placing this instance behind a reverse proxy like Nginx. You should also think about database and instance scalability, depending on your use case.
You should definitely check out the official BlockScout documentation as there a lot of customization options.
Last updated