├── .gitignore ├── .env ├── docker-compose.yml ├── .github └── workflows │ └── docker.yml ├── scripts └── entrypoint.sh ├── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /local-build 2 | /private 3 | /state 4 | Dockerfile.local 5 | .idea 6 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | GLOBAL_CONFIG_URL=https://ton.org/global.config.json 2 | MYTONCTRL_VERSION=master 3 | TELEMETRY=true 4 | IGNORE_MINIMAL_REQS=false 5 | MODE=validator 6 | DUMP=false 7 | ARCHIVE_TTL=86400 8 | STATE_TTL=86400 9 | VERBOSITY=1 10 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.3" 2 | services: 3 | ton-node: 4 | image: mytonctrl:2 5 | build: 6 | context: . 7 | dockerfile: Dockerfile 8 | args: 9 | GLOBAL_CONFIG_URL: ${GLOBAL_CONFIG_URL} 10 | MYTONCTRL_VERSION: ${MYTONCTRL_VERSION} 11 | TELEMETRY: ${TELEMETRY} 12 | IGNORE_MINIMAL_REQS: ${IGNORE_MINIMAL_REQS} 13 | MODE: ${MODE} 14 | restart: always 15 | tty: true 16 | volumes: 17 | - ton:/var/ton-work 18 | - mytoncore:/usr/local/bin/mytoncore 19 | network_mode: host 20 | environment: 21 | GLOBAL_CONFIG_URL: ${GLOBAL_CONFIG_URL} 22 | IGNORE_MINIMAL_REQS: ${IGNORE_MINIMAL_REQS} 23 | DUMP: ${DUMP} 24 | ARCHIVE_TTL: ${ARCHIVE_TTL} 25 | STATE_TTL: ${STATE_TTL} 26 | VERBOSITY: ${VERBOSITY} 27 | logging: 28 | driver: "json-file" 29 | options: 30 | max-size: 100m 31 | max-file: "3" 32 | volumes: 33 | ton: 34 | mytoncore: 35 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: Docker Ubuntu 22.04 image 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - 'main' 8 | 9 | env: 10 | REGISTRY: ghcr.io 11 | IMAGE_NAME: ${{ github.repository }} 12 | 13 | jobs: 14 | build-and-push: 15 | runs-on: ubuntu-22.04 16 | steps: 17 | - name: Check out repository 18 | uses: actions/checkout@v3 19 | with: 20 | submodules: 'recursive' 21 | 22 | - name: Set up QEMU 23 | uses: docker/setup-qemu-action@v3 24 | 25 | - name: Set up Docker Buildx 26 | uses: docker/setup-buildx-action@v3 27 | 28 | - name: Login to GitHub Container Registry 29 | uses: docker/login-action@v3 30 | with: 31 | registry: ${{ env.REGISTRY }} 32 | username: ${{ github.repository_owner }} 33 | password: ${{ secrets.GITHUB_TOKEN }} 34 | 35 | - name: Get next tag 36 | id: tag 37 | run: | 38 | git fetch --all --tags 39 | git tag -l 40 | NEW_TAG=v$(date +'%Y.%m') 41 | FOUND=$(git tag -l | grep $NEW_TAG | wc -l) 42 | if [ $FOUND -eq 0 ]; then 43 | echo "TAG=$NEW_TAG" >> $GITHUB_OUTPUT 44 | else 45 | echo "TAG=$NEW_TAG-$FOUND" >> $GITHUB_OUTPUT 46 | fi 47 | 48 | - name: Build and push 49 | id: docker_build 50 | uses: docker/build-push-action@v6 51 | with: 52 | platforms: linux/amd64 53 | push: true 54 | context: ./ 55 | tags: | 56 | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest 57 | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }} 58 | -------------------------------------------------------------------------------- /scripts/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # check machine configuration 5 | echo -e "Checking system requirements" 6 | 7 | cpus=$(nproc) 8 | memory=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}') 9 | CPUS=$(expr $(nproc) - 1) 10 | GLOBAL_CONFIG_URL=${GLOBAL_CONFIG_URL:-https://ton.org/testnet-global.config.json} 11 | 12 | echo "This machine has ${cpus} CPUs and ${memory}KB of Memory" 13 | if [ "$IGNORE_MINIMAL_REQS" != true ] && ([ "${cpus}" -lt 16 ] || [ "${memory}" -lt 64000000 ]); then 14 | echo "Insufficient resources. Requires a minimum of 16 processors and 64Gb RAM." 15 | exit 1 16 | fi 17 | 18 | echo "Setting global config..." 19 | wget ${GLOBAL_CONFIG_URL} -O /usr/bin/ton/global.config.json 20 | 21 | URL="https://dump.ton.org" 22 | if [ ! -f /var/ton-work/db/dump_done ]; then 23 | if [ "$DUMP" == true ] ; then 24 | if [[ "$GLOBAL_CONFIG_URL" == *"testnet"* ]]; then 25 | DUMP_NAME="latest_testnet" 26 | else 27 | DUMP_NAME="latest" 28 | fi 29 | echo "Start DownloadDump $DUMP_NAME" 30 | DUMPSIZE=$(curl --silent ${URL}/dumps/${DUMP_NAME}.tar.size.archive.txt) 31 | DISKSPACE=$(df -B1 --output=avail /var/ton-work | tail -n1) 32 | NEEDSPACE=$(expr 3 '*' "$DUMPSIZE") 33 | if [ "$DISKSPACE" -gt "$NEEDSPACE" ]; then 34 | (curl --silent ${URL}/dumps/${DUMP_NAME}.tar.lz | pv --force | plzip -d -n${CPUS} | tar -xC /var/ton-work/db) 2>&1 | stdbuf -o0 tr '\r' '\n' 35 | mkdir -p /var/ton-work/db/static /var/ton-work/db/import 36 | chown -R validator:validator /var/ton-work/db 37 | touch /var/ton-work/db/dump_done 38 | echo "Done DownloadDump $DUMP_NAME" 39 | else 40 | echo "A minimum of $NEEDSPACE bytes of free disk space is required" 41 | exit 1 42 | fi 43 | fi 44 | fi 45 | 46 | echo "Setting processor cores" 47 | sed -i -e "s/--threads\s[[:digit:]]\+/--threads ${CPUS}/g" /etc/systemd/system/validator.service 48 | 49 | echo "Configuring TTL and verbosity settings" 50 | # Set default values if not provided 51 | ARCHIVE_TTL=${ARCHIVE_TTL:-86400} 52 | STATE_TTL=${STATE_TTL:-86400} 53 | VERBOSITY=${VERBOSITY:-1} 54 | 55 | # Replace existing --verbosity value with environment variable 56 | sed -i -e "s/--verbosity\s[[:digit:]]\+/--verbosity ${VERBOSITY}/g" /etc/systemd/system/validator.service 57 | 58 | # Replace existing --archive-ttl value with environment variable 59 | sed -i -e "s/--archive-ttl\s[[:digit:]]\+/--archive-ttl ${ARCHIVE_TTL}/g" /etc/systemd/system/validator.service 60 | 61 | # Add --state-ttl parameter if not already present 62 | if ! grep -q "\-\-state-ttl" /etc/systemd/system/validator.service; then 63 | sed -i -e "s/--archive-ttl ${ARCHIVE_TTL}/--archive-ttl ${ARCHIVE_TTL} --state-ttl ${STATE_TTL}/g" /etc/systemd/system/validator.service 64 | else 65 | # Replace existing --state-ttl value if already present 66 | sed -i -e "s/--state-ttl\s[[:digit:]]\+/--state-ttl ${STATE_TTL}/g" /etc/systemd/system/validator.service 67 | fi 68 | 69 | echo "Starting validator" 70 | systemctl start validator 71 | echo "Starting mytoncore" 72 | systemctl start mytoncore 73 | 74 | echo "Service started!" 75 | exec /usr/bin/systemctl 76 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/ton-blockchain/ton:latest 2 | 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | ARG MYTONCTRL_VERSION=master 5 | ARG TELEMETRY=false 6 | ARG DUMP=false 7 | ARG MODE=validator 8 | ARG IGNORE_MINIMAL_REQS=true 9 | ARG GLOBAL_CONFIG_URL=https://ton.org/global.config.json 10 | 11 | RUN apt-get update \ 12 | && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y lsb-release software-properties-common gnupg gperf make cmake libblas-dev wget gcc openssl libgsl-dev zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev python3-dev python3-pip sudo git fio iproute2 plzip pv curl libjemalloc-dev ninja-build rocksdb-tools autoconf automake libtool iputils-ping \ 13 | && rm -rf /var/lib/apt/lists/* \ 14 | && mkdir -p /var/ton-work/db/static /var/ton-work/db/import /var/ton-work/db/keyring /usr/bin/ton /usr/bin/ton/lite-client /usr/bin/ton/validator-engine /usr/bin/ton/validator-engine-console /usr/bin/ton/utils /usr/src/ton/crypto/fift/lib/ /usr/src/ton/crypto/smartcont /usr/bin/ton/crypto \ 15 | && cd /usr/src/ton && git init && git remote add origin https://github.com/ton-blockchain/ton.git \ 16 | && wget https://apt.llvm.org/llvm.sh \ 17 | && chmod +x llvm.sh \ 18 | && ./llvm.sh 16 clang \ 19 | && ln /usr/bin/clang-16 /usr/bin/clang \ 20 | && ln /usr/bin/clang++-16 /usr/bin/clang++ \ 21 | && cp /usr/local/bin/lite-client /usr/bin/ton/lite-client/ \ 22 | && cp /usr/local/bin/validator-engine /usr/bin/ton/validator-engine \ 23 | && cp /usr/local/bin/validator-engine-console /usr/bin/ton/validator-engine-console/ \ 24 | && cp /usr/local/bin/generate-random-id /usr/bin/ton/utils/ \ 25 | && cp /usr/local/bin/fift /usr/bin/ton/crypto/ \ 26 | && cp /usr/local/bin/func /usr/bin/ton/crypto/ \ 27 | && cp /usr/lib/fift/* /usr/src/ton/crypto/fift/lib/ \ 28 | && cp -r /usr/share/ton/smartcont/* /usr/src/ton/crypto/smartcont/ \ 29 | && wget -nv https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py -O /usr/bin/systemctl \ 30 | && chmod +x /usr/bin/systemctl \ 31 | && wget https://raw.githubusercontent.com/ton-blockchain/mytonctrl/${MYTONCTRL_VERSION}/scripts/install.sh -O /tmp/install.sh \ 32 | && wget -nv ${GLOBAL_CONFIG_URL} -O /usr/bin/ton/global.config.json \ 33 | && if [ "$TELEMETRY" = false ]; then export TELEMETRY="-t"; else export TELEMETRY=""; fi && if [ "$IGNORE_MINIMAL_REQS" = true ]; then export IGNORE_MINIMAL_REQS="-i"; else export IGNORE_MINIMAL_REQS=""; fi \ 34 | && /bin/bash /tmp/install.sh ${TELEMETRY} ${IGNORE_MINIMAL_REQS} -b ${MYTONCTRL_VERSION} -m ${MODE} \ 35 | && ln -sf /proc/$$/fd/1 /usr/local/bin/mytoncore/mytoncore.log \ 36 | && ln -sf /proc/$$/fd/1 /var/log/syslog \ 37 | && sed -i 's/--logname \/var\/ton-work\/log//g' /etc/systemd/system/validator.service \ 38 | && sed -i 's/\[Service\]/\[Service\]\nStandardOutput=null\nStandardError=syslog/' /etc/systemd/system/validator.service \ 39 | && sed -i 's/\[Service\]/\[Service\]\nStandardOutput=null\nStandardError=syslog/' /etc/systemd/system/mytoncore.service \ 40 | && rm -rf /var/lib/apt/lists/* && rm -rf /root/.cache/pip 41 | 42 | COPY --chmod=755 ./scripts/entrypoint.sh /entrypoint.sh 43 | ENTRYPOINT ["/entrypoint.sh"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ton-docker-ctrl 2 | 3 | Tested operating systems: 4 | * Ubuntu 22.04 5 | * Ubuntu 24.04 6 | * Debian 12 7 | 8 | ## Prerequisites 9 | To run, you need docker-ce, docker-buildx-plugin, docker-compose-plugin: 10 | 11 | * [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/) 12 | * [Install Docker Engine on Debian](https://docs.docker.com/engine/install/debian/) 13 | 14 | Build environment variables (are configured in the .env file): 15 | 16 | * **GLOBAL_CONFIG_URL** - URL of the TON blockchain configuration (default: [Mainnet](https://ton.org/global.config.json)) 17 | * **MYTONCTRL_VERSION** - MyTonCtrl build branch (default **master**) 18 | * **TELEMETRY** - Enable/Disable telemetry (default **true**) 19 | * **IGNORE_MINIMAL_REQS** - Ignore hardware requirements (default **true**) 20 | * **MODE** - Install MyTonCtrl with specified mode (validator or liteserver, default **validator**) 21 | * **DUMP** - Use pre-packaged dump. Reduces duration of initial synchronization, but it takes time to download the dump. You can view the download status in the logs `docker compose logs -f`. (default **false**) 22 | * **ARCHIVE_TTL** - Archive time-to-live in seconds for the validator (default **86400**) 23 | * **STATE_TTL** - State time-to-live in seconds for the validator (default **86400**) 24 | * **VERBOSITY** - Verbosity level for the validator engine (default **1**) 25 | 26 | ## Run TON validator with MyTonCtrl v2 in docker 27 | 28 | This is the simplest and the quickest way to set up and start the TON validator. 29 | It will use a historical dump of data to speed up the initial sync process. 30 | It will not start validation unless you top up the wallet. 31 | This command will create two docker volumes `ton-work` and `mytoncore`. The first one will contain the blockchain data, and the second - MyTonCtrl settings and most importantly wallets' data. 32 | Real paths of these volumes can be found using `docker volume inspect ` command. 33 | 34 | We recommend to change default Docker volumes' location, since the blockchain's data can grow rapidly, and TON validator require fast disks. 35 | 36 | Also, make sure you backed up your wallet data, that can be found in `/wallets` 37 | 38 | * Start container in the background: `docker run -d --name ton-node -v ton-work:/var/ton-work -v mytoncore:/usr/local/bin/mytoncore -e DUMP="true" -it ghcr.io/ton-blockchain/ton-docker-ctrl:latest` 39 | * Watch logs: `docker logs ton-node` 40 | * Use MyTonCtrl, go inside the container `docker exec -ti ton-node bash` and type `mytonctrl`. 41 | 42 | ## Run Archive node with MyTonCtrl v2 in docker 43 | 44 | This command will not download a huge whole TON blockchain dump, but defines only TTL parameters for new blocks. 45 | 46 | * Run `docker run -d --name ton-node -v /mnt/data/ton-work1:/var/ton-work -v mytoncore:/usr/local/bin/mytoncore -e DUMP="true" -e ARCHIVE_TTL="1000000000" -e STATE_TTL="1000000000" -it ghcr.io/ton-blockchain/ton-docker-ctrl:latest` 47 | 48 | ## Build Docker image from sources and run MyTonCtrl v2: 49 | 50 | * Clone: `git clone https://github.com/ton-blockchain/ton-docker-ctrl.git && cd ./ton-docker-ctrl` 51 | * Build: `docker build -t ton-docker-ctrl .` 52 | * Run: `docker run -d -v ton-work:/var/ton-work -v mytoncore:/usr/local/bin/mytoncore --name ton-node ton-docker-ctrl:latest` 53 | * Connect `docker exec -ti ton-node bash` 54 | 55 | ## Upgrade MyTonCtrl docker image from repository: 56 | * Pull docker image: `docker pull docker pull ghcr.io/ton-blockchain/ton-docker-ctrl:latest` 57 | 58 | ## Migrate non-Docker fullnode or validator to a dockerized MyTonCtrl v2 59 | 60 | Specify paths to TON binaries and sources, as well as to TON work directory, but most importantly to MyTonCtrl settings and wallets. 61 | 62 | ```bash 63 | docker run -d --name ton-node --restart always \ 64 | -v /mnt/data/ton-work:/var/ton-work \ 65 | -v /usr/bin/ton:/usr/bin/ton \ 66 | -v /usr/src/ton:/usr/src/ton \ 67 | -v /home//.local/share:/usr/local/bin \ 68 | ghcr.io/ton-blockchain/ton-docker-ctrl:latest 69 | ``` 70 | 71 | Read the logs 72 | ```bash 73 | docker logs ton-node 74 | ``` 75 | 76 | Get inside the container and run MyTonCtrl 77 | ```bash 78 | docker exec -ti ton-node bash 79 | ``` 80 | 81 | Start the container skipping original entrypoint execution 82 | ```bash 83 | docker run -it --entrypoint=bash ghcr.io/ton-blockchain/ton-docker-ctrl:latest 84 | ``` 85 | 86 | Volume inspection 87 | ```bash 88 | 89 | docker volume ls 90 | docker volume inspect ton-work 91 | docker volume inspect mytoncore 92 | ``` 93 | 94 | Uninstall the TON node 95 | 96 | ```bash 97 | docker stop ton-node 98 | docker rm ton-node 99 | docker volume rm mytoncore ton-work 100 | ``` --------------------------------------------------------------------------------