-
Notifications
You must be signed in to change notification settings - Fork 0
Bce 8698 gal 445 create ton docker #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 15 commits
2d0d9fc
4fc4b2f
b30d67f
05a2739
0f9f63d
622a799
d4b7dbf
fef4b46
ef6168b
df0e105
6502afa
6303f2e
4c8e2a3
6e34083
4f11052
a77c094
f0a3613
84a593d
8c2a525
28a5f01
f9392c8
6a65b14
c60d138
8d224ef
8a0f88f
29150e5
59c77c9
85e9102
990866b
68bc88a
368fcf4
0e10ef3
279edfb
bdc4899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,7 @@ | |
| *.bak | ||
| *.original | ||
| custom.yml | ||
| .idea/ | ||
| *.iml | ||
| *.ipr | ||
| *.iws | ||
| 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 | ||
| 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 | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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* ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| __docompose exec ton mytonctrl --version || true | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| 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"] |
| 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)" | ||
|
||
| 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." | ||
| 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: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How will ton be accessed using traefik? No labels
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
| 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"] |
| 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}" | ||
|
||
|
|
||
| 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 "$@" | ||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed