Skip to content

Commit

Permalink
Updated build
Browse files Browse the repository at this point in the history
  • Loading branch information
kdimentionaltree committed Jan 20, 2025
1 parent e5ca057 commit d9db299
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions docker-compose.swarm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3.9'
services:
http-api-cache:
image: redis:latest
command: redis-server --maxclients 100000
networks:
- internal
deploy:
Expand Down
19 changes: 11 additions & 8 deletions ton-http-api/.docker/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
FROM ubuntu:20.04 as tonlib-builder
FROM ubuntu:24.04 as tonlib-builder
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata

RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev pkg-config libsecp256k1-dev libsodium-dev ninja-build
RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget \
git curl libreadline-dev ccache libmicrohttpd-dev pkg-config \
liblz4-dev libsodium-dev libsecp256k1-dev ninja-build autoconf libtool

# build tonlib
WORKDIR /

# remove /tree/<commit> to build master branch
ARG TON_REPO
ARG TON_BRANCH
RUN git clone --recurse-submodules https://github.com/${TON_REPO:-ton-blockchain/ton}
RUN git clone --recursive --branch ${TON_BRANCH:-master} https://github.com/${TON_REPO:-ton-blockchain/ton}
WORKDIR /ton
RUN git checkout ${TON_BRANCH:-master} && git submodule update --init --recursive

# fix lib version and patch logging
RUN mkdir /ton/build
WORKDIR /ton/build
ENV CC clang
ENV CXX clang++
RUN cmake -DCMAKE_BUILD_TYPE=Release .. -GNinja
RUN cmake -DPORTABLE=1 -DCMAKE_BUILD_TYPE=Release .. -GNinja
RUN ninja -j$(nproc) tonlibjson

FROM ubuntu:20.04
# RUN ls -la /ton/build/ && exit 1

FROM ubuntu:24.04

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get install -y git cmake wget python3 python3-pip curl libsecp256k1-dev libsodium-dev
RUN apt-get install -y git cmake wget python3 python3-pip curl libsodium-dev libsecp256k1-dev

# python requirements
ADD ./requirements.txt /tmp/requirements.txt
RUN python3 -m pip install --no-cache-dir -r /tmp/requirements.txt
RUN python3 -m pip install --break-system-packages --no-cache-dir -r /tmp/requirements.txt

# app
COPY . /app
Expand Down
3 changes: 2 additions & 1 deletion ton-http-api/pyTON/api/api_v2/endpoints/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ async def send_boc_return_hash(
boc = base64.b64decode(boc)
res = await tonlib.raw_send_message_return_hash(boc)
if res.get('@type') == 'raw.extMessageInfo':
logger.info("External message accepted: {hash}", hash=res.get('hash'))
logger.info("External message accepted, hash: {hash}, boc: {boc}", hash=res.get('hash'), boc=base64.b64encode(boc).decode('utf8'))
if settings.webserver.boc_endpoint is not None:
background_tasks.add_task(send_boc_to_external_endpoint, base64.b64encode(boc).decode('utf8'))
return res
Expand All @@ -534,6 +534,7 @@ async def send_boc_return_hash_no_error(
raise HTTPException(status_code=400, detail=f"Error: {e}")
if res.get('@type') == 'raw.extMessageInfo':
logger.info("External message accepted: {hash}", hash=res.get('hash'))
logger.info("ExtBoc: {boc}", boc=base64.b64encode(boc).decode('utf8'))
if settings.webserver.boc_endpoint is not None:
background_tasks.add_task(send_boc_to_external_endpoint, base64.b64encode(boc).decode('utf8'))
return res
Expand Down
5 changes: 4 additions & 1 deletion ton-http-api/pyTON/core/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def wrapper(*args, **kwargs):
class RedisCacheManager:
def __init__(self, cache_settings: RedisCacheSettings):
self.cache_settings = cache_settings
self.cache_redis = redis.asyncio.from_url(f"redis://{cache_settings.redis.endpoint}:{cache_settings.redis.port}")
redis_url = f"redis://{cache_settings.redis.endpoint}:{cache_settings.redis.port}"
# if self.cache_settings.redis.timeout is not None:
# redis_url += '?timeout={self.cache_settings.redis.timeout}'
self.cache_redis = redis.asyncio.from_url(redis_url)

def cached(self, expire=0, check_error=True):
storage_class = TonlibResultRedisStorage if check_error else Aioredis2Storage
Expand Down

0 comments on commit d9db299

Please sign in to comment.