Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2d0d9fc
BCE-8698: Added ton docker
lipika-pal Feb 27, 2026
4fc4b2f
BCE-8698: ports updated to ton docker
lipika-pal Feb 27, 2026
b30d67f
BCE-8698: config updated for ton docker
lipika-pal Feb 27, 2026
05a2739
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
0f9f63d
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
622a799
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
d4b7dbf
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
fef4b46
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
ef6168b
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
df0e105
Remove .idea from repo and add to gitignore
lipika-pal Mar 2, 2026
6502afa
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
6303f2e
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
4c8e2a3
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
6e34083
BCE-8698: config updated for ton docker
lipika-pal Mar 2, 2026
4f11052
BCE-8698: config updated for ton docker
lipika-pal Mar 3, 2026
a77c094
BCE-8698: added ton http api and refactored ton node
lipika-pal Mar 4, 2026
f0a3613
BCE-8698: lint fixes
lipika-pal Mar 4, 2026
84a593d
BCE-8698: lint fixes
lipika-pal Mar 4, 2026
8c2a525
BCE-8698: lint fixes
lipika-pal Mar 4, 2026
28a5f01
BCE-8698: traefik labels added
lipika-pal Mar 5, 2026
f9392c8
BCE-8698: fix public ip detection
lipika-pal Mar 5, 2026
6a65b14
BCE-8698: fix snapshot
lipika-pal Mar 5, 2026
c60d138
BCE-8698: auto generate liteserver config for ton-http-api
lipika-pal Mar 5, 2026
8d224ef
BCE-8698: lint fixes
lipika-pal Mar 5, 2026
8a0f88f
BCE-8698: fixing ton-http-api liteserver config generation
lipika-pal Mar 5, 2026
29150e5
BCE-8698: fix ton http api
lipika-pal Mar 5, 2026
59c77c9
BCE-8698: added ethd check-sync command
lipika-pal Mar 5, 2026
85e9102
BCE-8698: updated ton-http-api checking ton node sync
lipika-pal Mar 5, 2026
990866b
BCE-8698: fixed sync check
lipika-pal Mar 5, 2026
68bc88a
BCE-8698: refactor
lipika-pal Mar 5, 2026
368fcf4
BCE-8698:fixed ton-http-api
lipika-pal Mar 6, 2026
0e10ef3
BCE-8698: refactored
lipika-pal Mar 6, 2026
279edfb
BCE-8698: check sync updated
lipika-pal Mar 6, 2026
bdc4899
BCE-8698: ton node and http-api updated
lipika-pal Mar 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
*.bak
*.original
custom.yml
.idea/
*.iml
*.ipr
*.iws
45 changes: 45 additions & 0 deletions default.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# The settings are in .env, use "nano .env". Don't edit default.env itself.
COMPOSE_FILE=ton.yml

# ---- Required ----
# Public IP address of the host
PUBLIC_IP=YOUR.PUBLIC.IP.HERE

# ---- Network / config ----
TON_BRANCH=mainnet
#TON_NETWORK=mainnet
GLOBAL_CONFIG_URL=https://ton.org/global.config.json
#https://ton.org/testnet-global.config.json

MYTONCTRL_VERSION=master
TELEMETRY=true
IGNORE_MINIMAL_REQS=true
MODE=liteserver

ARCHIVE_TTL=2592000
STATE_TTL=86400
VERBOSITY=1

LITESERVER_PORT=
VALIDATOR_PORT=
VALIDATOR_CONSOLE_PORT=

# ---- Init dump settings ----
USE_TON_DUMP=true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show example of dump url, like for mainnet here as initial values

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

TON_WORK_DIR=/var/ton-work
DUMP_BASE_URL=https://dump.ton.org
DUMP_NAME=
DUMP_THREADS=
WAIT_FOR_DUMP=true
DUMP=false

# ---- Docker build targets ----
TON_DOCKERFILE=Dockerfile.binary
TON_DOCKER_TAG=latest
TON_DOCKER_REPO=ghcr.io/ton-blockchain/ton-docker-ctrl

# You can pin the version of your Docker scripts here
SCRIPT_TAG=

# Used by optd update - please do not adjust
ENV_VERSION=1
25 changes: 0 additions & 25 deletions default.env.example

This file was deleted.

4 changes: 2 additions & 2 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ version() {
# Multiple clients are in multiple case statements. Mutually exclusive clients are in one case statement
# Avoid the use of ;;&
case "${__value}" in
*x.yml* )
__docompose exec x-geth x-geth version
*ton.yml* )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not working, make sure ./ethd commands work all of them, ie ./ethd version

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

__docompose exec ton mytonctrl --version || true
;;
esac
}
Expand Down
10 changes: 10 additions & 0 deletions init/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates bash curl pv plzip tar \
&& rm -rf /var/lib/apt/lists/*

COPY ./fetch-snapshot.sh /usr/local/bin/fetch-snapshot.sh
RUN chmod 755 /usr/local/bin/fetch-snapshot.sh

ENTRYPOINT ["/usr/local/bin/fetch-snapshot.sh"]
74 changes: 74 additions & 0 deletions init/fetch-snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
set -euo pipefail

TON_WORK_DIR="${TON_WORK_DIR:-/var/ton-work}"
DB_DIR="${TON_WORK_DIR}/db"
DUMP_BASE_URL="${DUMP_BASE_URL:-https://dump.ton.org}"
GLOBAL_CONFIG_URL="${GLOBAL_CONFIG_URL:-https://ton.org/global.config.json}"
USE_TON_DUMP="${USE_TON_DUMP:-false}"
DUMP_NAME="${DUMP_NAME:-}"
DUMP_THREADS="${DUMP_THREADS:-}"

mkdir -p "${DB_DIR}"

if [[ "${USE_TON_DUMP}" != "true" ]]; then
echo "[ton-init] USE_TON_DUMP=false; creating dump_done marker."
mkdir -p "${DB_DIR}"
touch "${DB_DIR}/dump_done"
exit 0
fi

if [[ -f "${DB_DIR}/dump_done" ]]; then
echo "[ton-init] dump already present (${DB_DIR}/dump_done)."
exit 0
fi

# Auto-select dump name if not provided
if [[ -z "${DUMP_NAME}" ]]; then
if [[ "${GLOBAL_CONFIG_URL}" == *"testnet"* ]]; then
DUMP_NAME="latest_testnet"
else
DUMP_NAME="latest"
fi
fi

URL_SIZE="${DUMP_BASE_URL}/dumps/${DUMP_NAME}.tar.size.archive.txt"
URL_DUMP="${DUMP_BASE_URL}/dumps/${DUMP_NAME}.tar.lz"

echo "[ton-init] Selected dump: ${DUMP_NAME}"
echo "[ton-init] Size URL: ${URL_SIZE}"
echo "[ton-init] Dump URL: ${URL_DUMP}"

DUMPSIZE="$(curl --fail --retry 5 --retry-delay 5 --silent "${URL_SIZE}" || true)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you use aria2 to download instead of curl especially for retry/resume

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if [[ -z "${DUMPSIZE}" ]]; then
echo "[ton-init] Could not fetch dump size from ${URL_SIZE}"
exit 1
fi

DISKSPACE="$(df -B1 --output=avail "${TON_WORK_DIR}" | tail -n1 | tr -d ' ')"
NEEDSPACE="$(( 3 * DUMPSIZE ))" # 3x safety margin

echo "[ton-init] Available bytes: ${DISKSPACE}"
echo "[ton-init] Required bytes : ${NEEDSPACE}"

if (( DISKSPACE <= NEEDSPACE )); then
echo "[ton-init] Not enough free space. Need at least ${NEEDSPACE} bytes free on ${TON_WORK_DIR}."
exit 1
fi

if [[ -z "${DUMP_THREADS}" ]]; then
DUMP_THREADS="$(nproc || echo 4)"
fi
echo "[ton-init] Using ${DUMP_THREADS} threads for plzip"

curl --fail --retry 5 --retry-delay 10 --silent "${URL_DUMP}" \
| pv --force \
| plzip -d -n"${DUMP_THREADS}" \
| tar -xC "${DB_DIR}"

mkdir -p "${DB_DIR}/static" "${DB_DIR}/import"
touch "${DB_DIR}/dump_done"

chown -R 1000:1000 "${TON_WORK_DIR}" || true

echo "[ton-init] Dump download + extract complete."
74 changes: 74 additions & 0 deletions ton.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
x-logging: &logging
logging:
driver: json-file
options:
max-size: 100m
max-file: "3"
tag: '{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}'

services:
ton-init:
restart: "no"
build:
context: ./init
dockerfile: Dockerfile
image: init:ton
pull_policy: never
environment:
- USE_TON_DUMP=${USE_TON_DUMP:-false}
- TON_WORK_DIR=${TON_WORK_DIR:-/var/ton-work}
- GLOBAL_CONFIG_URL=${GLOBAL_CONFIG_URL:-https://ton.org/global.config.json}
- DUMP_BASE_URL=${DUMP_BASE_URL:-https://dump.ton.org}
- DUMP_NAME=${DUMP_NAME:-}
- DUMP_THREADS=${DUMP_THREADS:-}
volumes:
- ton-work:/var/ton-work
- /etc/localtime:/etc/localtime:ro
<<: *logging

ton:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will ton be accessed using traefik? No labels

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

restart: unless-stopped
tty: true
build:
context: ./ton
dockerfile: ${TON_DOCKERFILE:-Dockerfile.binary}
args:
- DOCKER_TAG=${TON_DOCKER_TAG}
- DOCKER_REPO=${TON_DOCKER_REPO}
image: ton:${TON_BRANCH:-latest}
container_name: ton
pull_policy: never
stop_grace_period: 5m
environment:
- TON_BRANCH=${TON_BRANCH:-latest}
- PUBLIC_IP=${PUBLIC_IP}
- GLOBAL_CONFIG_URL=${GLOBAL_CONFIG_URL}
- MYTONCTRL_VERSION=${MYTONCTRL_VERSION:-master}
- TELEMETRY=${TELEMETRY:-true}
- IGNORE_MINIMAL_REQS=${IGNORE_MINIMAL_REQS:-true}
- MODE=${MODE:-liteserver}
- DUMP=${DUMP:-false}
- ARCHIVE_TTL=${ARCHIVE_TTL:-2592000}
- STATE_TTL=${STATE_TTL:-86400}
- VERBOSITY=${VERBOSITY:-1}
- LITESERVER_PORT=${LITESERVER_PORT:-}
- VALIDATOR_PORT=${VALIDATOR_PORT:-}
- VALIDATOR_CONSOLE_PORT=${VALIDATOR_CONSOLE_PORT:-}
- WAIT_FOR_DUMP=${WAIT_FOR_DUMP:-false}
- TON_WORK_DIR=${TON_WORK_DIR:-/var/ton-work}
volumes:
- ton-work:/var/ton-work
- mytoncore:/usr/local/bin/mytoncore
- /etc/localtime:/etc/localtime:ro
ports:
- ${VALIDATOR_PORT:-30001}:${VALIDATOR_PORT:-30001}/udp
- ${LITESERVER_PORT:-30003}:${LITESERVER_PORT:-30003}/tcp
- ${VALIDATOR_CONSOLE_PORT:-30002}:${VALIDATOR_CONSOLE_PORT:-30002}/tcp
depends_on:
ton-init:
condition: service_completed_successfully
<<: *logging

volumes:
ton-work:
mytoncore:
22 changes: 22 additions & 0 deletions ton/Dockerfile.binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG DOCKER_REPO=ghcr.io/ton-blockchain/ton-docker-ctrl
ARG DOCKER_TAG=latest

FROM ${DOCKER_REPO}:${DOCKER_TAG}

USER root

# Optional tools (safe even if base changes between apt/apk)
RUN if command -v apt-get >/dev/null 2>&1; then \
apt-get update && apt-get install -y --no-install-recommends \
ca-certificates tzdata bash curl wget jq \
&& rm -rf /var/lib/apt/lists/*; \
elif command -v apk >/dev/null 2>&1; then \
apk add --no-cache ca-certificates tzdata bash curl wget jq; \
else \
echo "No known package manager found; skipping OS packages" >&2; \
fi

COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod -R 755 /usr/local/bin/docker-entrypoint.sh

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
34 changes: 34 additions & 0 deletions ton/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

: "${PUBLIC_IP:?PUBLIC_IP must be set (public IPv4) for TON node to start}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you detect the public IP of the server automatically like we do on other repos. Dont need to be in .env

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Implemented automatic IPv4 detection.
  • PUBLIC_IP environment variable remains available as manual override for edge cases where auto-detection doesn't work.

The upstream ton-docker-ctrl has PUBLIC_IP as a configuration variable: https://github.com/ton-blockchain/ton-docker-ctrl?tab=readme-ov-file#configuration

This PR enhances it by adding automatic detection, so PUBLIC_IP only needs to be set manually in special network configurations.


TON_WORK_DIR="${TON_WORK_DIR:-/var/ton-work}"

if [[ "${WAIT_FOR_DUMP:-false}" == "true" && "${USE_TON_DUMP:-false}" == "true" ]]; then
if [[ -f "${TON_WORK_DIR}/db/dump_done" ]]; then
echo "[ton] dump_done already present."
else
echo "[ton] Waiting for ${TON_WORK_DIR}/db/dump_done (WAIT_FOR_DUMP=true)..."
for ((n=0; n<720; n++)); do
[[ -f "${TON_WORK_DIR}/db/dump_done" ]] && \
echo "[ton] dump_done found." && break
sleep 10
done
fi
fi

export DUMP="${DUMP:-false}"
export VALIDATOR_PORT="${VALIDATOR_PORT:-}"
export LITESERVER_PORT="${LITESERVER_PORT:-}"
export VALIDATOR_CONSOLE_PORT="${VALIDATOR_CONSOLE_PORT:-}"

if [[ -f "${TON_WORK_DIR}/db/mtc_done" ]]; then
if [[ ! -f /etc/systemd/system/validator.service || ! -f /etc/systemd/system/mytoncore.service ]]; then
echo "[ton] mtc_done exists but systemd unit files are missing; forcing reinstall"
rm -f "${TON_WORK_DIR}/db/mtc_done"
rm -rf /usr/src/mytonctrl || true
fi
fi

exec /scripts/entrypoint.sh "$@"