-
NGINX: https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04
-
Docker Compose: https://docs.docker.com/compose/install/
-
Certbot: https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx.html
-
Git:
sudo apt install git -
PostgreSQL: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04
-
Komodod - https://github.com/komodoplatform/komodo (you can use bootstrap from https://www.dexstats.info/bootstrap.php to speed things up)
-
Pip3:
sudo apt install python3-pipthenpip3 install --upgrade setuptools wheel -
Psychpg2
sudo apt-get install python-psycopg2thensudo apt-get install python3-dev build-essential libpq-dev libgnutls28-dev gcc -
mysql-client / connector
sudo apt-get install default-libmysqlclient-dev build-essential python3-mysql.connector
git clone https://github.com/smk762/kmd_ntx_stats_docker
cd kmd_ntx_stats_docker
Install Python Packages: pip3 install -r requirements.txt
sudo docker compose build (needs to be run to apply code changes)
sudo docker compose up (run to launch containers)
-
pgsql credentials
-
django secret key
-
allowed hosts
Make migrations: "docker compose run web python3 manage.py makemigrations"
Apply migrations: "docker compose run web python3 manage.py migrate"
Collect static files: "docker compose run web python3 manage.py collectstatic"
docker compose run web python3 manage.py createsuperuser --email [email protected] --username messiah
See https://docs.djangoproject.com/en/3.0/ref/django-admin/ for more django admin commands.
cd ~/kmd_ntx_stats_docker
docker compose build
sudo chown $USER:$USER /home/$USER/kmd_ntx_stats_docker/postgres-data -R
docker compose build
sudo cp -R static /var/www/stats.kmd.io/html
add coin parmas to scripts/base_58.py
run scripts/populate_coins_table.py
run scripts/populate_balances_table.py
run scripts/populate_addresses_table.py
Check web pages to confirm display / no errors.
- to make migrations, use
docker compose run web python3 manage.py makemigrations - to apply migrations, use
docker compose run web python3 manage.py migrate - to update static files, use
docker compose run web python3 manage.py collectstatic
docker exec -it <pgsql_container_name> bashapt update & apt install nanonano ./var/lib/postgresql/data/postgresql.conf- change max_connections to 1000
- change max_wal_size to 2gb
- log_rotation_size to 100mb
docker compose run web python3 manage.py findstatic --verbosity 2 static
sudo nano /home/$USER/kmd_ntx_stats_docker/postgres-data/pg_hba.conf
sudo chown $USER:$USER /home/$USER/kmd_ntx_stats_docker/postgres-data -R
docker system prune -a --volumes
Use the helper scripts in util/ to safely move the Postgres data directory between servers without copying raw volumes.
- Ensure the stack is up with
docker compose up -d db. - Run
./util/export_postgres.sh /absolute/path/to/postgres.sql.gz(the path is optional; a timestamped file is written tobackups/by default). - Copy the resulting
.sql.gzfile to secure storage or directly to the destination host.
- Clone this repository, create the
.envfiles, and bring the database online:docker compose up -d db. - Transfer the dump file to the new host.
- Run
./util/import_postgres.sh /absolute/path/to/postgres.sql.gz. The script drops and recreates thepublicschema before streaming the dump into Postgres. - Start or restart the rest of the stack (
docker compose up -d) and follow the standard Django migration/static collection steps if needed.
This workflow keeps the migration deterministic, avoids mismatched Postgres minor versions, and allows you to archive backups under backups/ (ignored by git).
See docs/production-deployment.md for a step-by-step server hardening and deployment checklist, including SSL termination, monitoring, and backup rotation guidance.