1、拉取github代码
mkdir /data
git clone https://github.com/toncenter/ton-http-api.git
cd ton-http-api
2、创建环境变量
./configure.py
cat .env
TON_API_CACHE_ENABLED=0
TON_API_CACHE_REDIS_ENDPOINT=cache_redis
TON_API_CACHE_REDIS_PORT=6379
TON_API_CACHE_REDIS_TIMEOUT=1
TON_API_LOGS_JSONIFY=0
TON_API_LOGS_LEVEL=ERROR
TON_API_GET_METHODS_ENABLED=1
TON_API_HTTP_PORT=80
TON_API_JSON_RPC_ENABLED=1
TON_API_ROOT_PATH=/
TON_API_WEBSERVERS_WORKERS=1
TON_API_TONLIB_LITESERVER_CONFIG=private/mainnet.json
TON_API_TONLIB_KEYSTORE=/tmp/ton_keystore/
TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER=50
TON_API_TONLIB_CDLL_PATH=
TON_API_TONLIB_REQUEST_TIMEOUT=10
TON_API_GUNICORN_FLAGS=
COMPOSE_FILE=docker-compose.yaml
3、下载mainnet.json文件
主网是mainnet.json,测试网是testnet.json
mkdir private
curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json
curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json
4、更改下docker-compose.yaml文件,将ton_keystore映射出来
将下面部分加入到docker-compose.yaml中
volumes:- ./ton_keystore:/tmp/ton_keystore
具体如下
version: '3.7'
services:main:image: toncenter/ton-http-apibuild: context: ton-http-apidockerfile: .docker/Dockerfileports:- ${TON_API_HTTP_PORT:-8081}:8081environment:- TON_API_CACHE_ENABLED- TON_API_CACHE_REDIS_ENDPOINT- TON_API_CACHE_REDIS_PORT- TON_API_CACHE_REDIS_TIMEOUT- TON_API_LOGS_JSONIFY- TON_API_LOGS_LEVEL- TON_API_TONLIB_LITESERVER_CONFIG=/run/secrets/liteserver_config- TON_API_TONLIB_KEYSTORE- TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER- TON_API_TONLIB_CDLL_PATH- TON_API_TONLIB_REQUEST_TIMEOUT- TON_API_GET_METHODS_ENABLED- TON_API_JSON_RPC_ENABLED- TON_API_ROOT_PATHrestart: unless-stoppedvolumes:- ./ton_keystore:/tmp/ton_keystore networks:- internalsecrets:- liteserver_configcommand: -c "gunicorn -k uvicorn.workers.UvicornWorker -w ${TON_API_WEBSERVERS_WORKERS} --bind 0.0.0.0:8081 ${TON_API_GUNICORN_FLAGS} pyTON.main:app"healthcheck:test: curl -sS http://127.0.0.1:8081${TON_API_ROOT_PATH}/healthcheck || echo 1interval: 15stimeout: 3sretries: 12
secrets:liteserver_config:file: ${TON_API_TONLIB_LITESERVER_CONFIG:-./private/mainnet.json}
networks:internal:
5、启动容器
docker-compose up -d
docker-compose ps
6、验证
在web浏览器上打开http://ip:80,获取主节点信息