@@ -102,33 +102,63 @@ ENV VCPKG_FORCE_SYSTEM_BINARIES=1
102102ENV VCPKG_DISABLE_METRICS=1
103103ENV VCPKG_USE_ARIA2=1
104104ENV VCPKG_DOWNLOADER=aria2
105+ ENV VCPKG_DOWNLOAD_TOOL=aria2
105106ENV VCPKG_MAX_CONCURRENCY=4
107+ ENV VCPKG_BUILD_TYPE=release
106108ENV VCPKG_INSTALLED_DIR=/src/vcpkg_installed
107109# Local binary cache directory for faster multi-arch builds
108110RUN mkdir -p /root/.cache/vcpkg/archives && chmod -R 755 /root/.cache/vcpkg
109111
110- # Install dependencies via vcpkg - will use cache if available, download if needed
112+ # Install dependencies via vcpkg - use cache as fallback, but allow online downloads
111113# Uses build arg VCPKG_ASSET_URL for asset source (default: https://vcpkg.io/assets)
114+ RUN set -eux; \
115+ export VCPKG_DOWNLOAD_TOOL=aria2; export VCPKG_USE_ARIA2=1; export VCPKG_DOWNLOADER=aria2; \
116+ BOOST_PKGS="algorithm align array asio assert atomic beast bind chrono concept-check config container container-hash context conversion core coroutine date_time describe detail dynamic-bitset endian exception filesystem function function-types functional fusion integer intrusive io iterator lexical_cast locale logic math move mp11 mpl multiprecision numeric-conversion optional pool predef preprocessor random range ratio regex scope scope-exit smart-ptr static-assert static-string system thread throw-exception tokenizer tuple type-index type-traits typeof unordered utility variant2 winapi" ; \
117+ for pkg in $BOOST_PKGS; do \
118+ repo_slug=$(echo "$pkg" | tr '-' '_' ); \
119+ file=boostorg-${repo_slug}-boost-1.86.0.tar.gz; \
120+ if [ -f /opt/vcpkg/downloads/$file ]; then \
121+ echo "Using cached $file" ; \
122+ continue; \
123+ fi; \
124+ for attempt in 1 2 3 4 5; do \
125+ echo "Downloading $file (attempt ${attempt}/5)" ; \
126+ if aria2c --retry-wait=5 --max-tries=5 --timeout=30 --dir=/opt/vcpkg/downloads --out=$file \
127+ https://github.com/boostorg/${repo_slug}/archive/boost-1.86.0.tar.gz; then \
128+ break; \
129+ fi; \
130+ if [ "$attempt" -eq 5 ]; then \
131+ echo "Download $file failed after 5 attempts" ; \
132+ exit 1; \
133+ fi; \
134+ sleep 10; \
135+ done; \
136+ done
137+
112138RUN . /etc/profile.d/vcpkg.sh && \
113139 # Check if cache has actual content (excluding placeholder files)
114140 CACHE_FILES=$(find ${VCPKG_ROOT}/downloads -type f ! -name '.gitkeep' ! -name 'README.md' | wc -l) && \
115- if [ "$CACHE_FILES" -gt 0 ]; then \
116- echo "==> Using OFFLINE mode with cached downloads ($CACHE_FILES files)" ; \
117- export VCPKG_ASSET_SOURCES="files,/opt/vcpkg/downloads,readwrite" ; \
118- else \
119- echo "==> Using ONLINE mode (no cache found, will download packages)" ; \
120- ASSET_URL=${VCPKG_ASSET_URL:-https://vcpkg.io/assets}; \
121- export VCPKG_ASSET_SOURCES="x-azurl,$ASSET_URL,readwrite" ; \
122- echo "Asset source: $ASSET_URL" ; \
123- fi && \
141+ echo "==> Found $CACHE_FILES cached download files" && \
142+ echo "==> Using HYBRID mode: cache first, online fallback for missing packages" && \
143+ # Use local cache first, then fall back to online downloads if files are missing
144+ export VCPKG_ASSET_SOURCES="clear;files,/opt/vcpkg/downloads,readwrite;x-azurl,https://vcpkg.io/assets,readwrite" && \
124145 echo "Installing dependencies for ${VCPKG_TRIPLET}..." && \
125146 set -eux; \
126147 export VCPKG_BINARY_SOURCES="clear;files,/src/vcpkg_installed,readwrite;files,/opt/vcpkg/downloads,readwrite" ; \
127- ${VCPKG_ROOT}/vcpkg install --triplet=${VCPKG_TRIPLET} 2>&1 | tee /tmp/vcpkg_install.log || ( \
128- echo "vcpkg install failed; tail of log:" ; \
129- tail -n 100 /tmp/vcpkg_install.log; \
130- exit 1 \
131- )
148+ export VCPKG_DOWNLOAD_TOOL=aria2; export VCPKG_USE_ARIA2=1; export VCPKG_DOWNLOADER=aria2; \
149+ for attempt in 1 2 3; do \
150+ echo "vcpkg install attempt ${attempt}/3" ; \
151+ if ${VCPKG_ROOT}/vcpkg install --triplet=${VCPKG_TRIPLET} 2>&1 | tee /tmp/vcpkg_install.log; then \
152+ break; \
153+ fi; \
154+ if [ "$attempt" -eq 3 ]; then \
155+ echo "vcpkg install failed after 3 attempts; tail of log:" ; \
156+ tail -n 200 /tmp/vcpkg_install.log; \
157+ exit 1; \
158+ fi; \
159+ echo "vcpkg install failed; retrying in 15s..." ; \
160+ sleep 15; \
161+ done
132162
133163# Copy source code
134164COPY CMakeLists.txt ./
@@ -137,22 +167,14 @@ COPY include ./include
137167COPY cmake ./cmake
138168COPY src ./src
139169
140- # Optional: enable embedded LLM via llama.cpp
141- ARG ENABLE_LLM=OFF
170+ # Enable embedded LLM via llama.cpp (always ON)
171+ ARG ENABLE_LLM=ON
142172ARG LLAMA_GIT_REF=master
143173
144- # Use local llama.cpp via BuildKit additional context "llama" if provided; else clone via git
145- RUN --mount=type=bind,from=llama,src=/,target=/tmp/llama-src \
146- if [ "${ENABLE_LLM}" = "ON" ]; then \
147- if [ -d "/tmp/llama-src" ] && [ "$(ls -A /tmp/llama-src)" ]; then \
148- echo "Using local llama.cpp from additional build context" ; \
149- cp -a /tmp/llama-src /src/llama.cpp; \
150- else \
151- echo "Cloning llama.cpp (${LLAMA_GIT_REF})" ; \
152- git clone --depth=1 https://github.com/ggerganov/llama.cpp.git /src/llama.cpp && \
153- (cd /src/llama.cpp && git fetch --depth=1 origin ${LLAMA_GIT_REF} || true && git checkout ${LLAMA_GIT_REF} || true); \
154- fi; \
155- fi
174+ # Clone llama.cpp for embedded LLM support
175+ RUN echo "Cloning llama.cpp (${LLAMA_GIT_REF}) - LLM support enabled" ; \
176+ git clone --depth=1 https://github.com/ggerganov/llama.cpp.git /src/llama.cpp && \
177+ (cd /src/llama.cpp && git fetch --depth=1 origin ${LLAMA_GIT_REF} || true && git checkout ${LLAMA_GIT_REF} || true)
156178
157179# All vcpkg manifest dependencies are installed above (with retries)
158180
@@ -318,16 +340,19 @@ VOLUME ["/var/lib/themisdb"]
318340
319341# Port mappings for all interfaces (optional ones require explicit build flags)
320342# Core ports (always available):
321- EXPOSE 8080 # HTTP/1.1 REST API, GraphQL, HTTP/2 (if enabled with -DTHEMIS_ENABLE_HTTP2=ON)
322- EXPOSE 18765 # Binary Wire Protocol, gRPC
323- EXPOSE 4318 # OpenTelemetry/Prometheus metrics (OTLP)
343+ # - 8080: HTTP/1.1 REST API, GraphQL, HTTP/2 (if enabled with -DTHEMIS_ENABLE_HTTP2=ON)
344+ # - 18765: Binary Wire Protocol, gRPC
345+ # - 4318: OpenTelemetry/Prometheus metrics (OTLP)
346+ EXPOSE 8080
347+ EXPOSE 18765
348+ EXPOSE 4318
324349
325350# Optional protocol ports (require explicit build flags):
326- # EXPOSE 1883 # MQTT plain (requires -DTHEMIS_ENABLE_MQTT=ON)
327- # EXPOSE 8883 # MQTT over TLS (requires -DTHEMIS_ENABLE_MQTT=ON)
328- # EXPOSE 8083 # MQTT over WebSocket (requires -DTHEMIS_ENABLE_MQTT=ON)
329- # EXPOSE 5432 # PostgreSQL Wire Protocol (requires -DTHEMIS_ENABLE_POSTGRES_WIRE=ON)
330- # EXPOSE 3000 # MCP server for LLM integration (requires -DTHEMIS_ENABLE_MCP=ON)
351+ # - 1883: MQTT plain (requires -DTHEMIS_ENABLE_MQTT=ON)
352+ # - 8883: MQTT over TLS (requires -DTHEMIS_ENABLE_MQTT=ON)
353+ # - 8083: MQTT over WebSocket (requires -DTHEMIS_ENABLE_MQTT=ON)
354+ # - 5432: PostgreSQL Wire Protocol (requires -DTHEMIS_ENABLE_POSTGRES_WIRE=ON)
355+ # - 3000: MCP server for LLM integration (requires -DTHEMIS_ENABLE_MCP=ON)
331356
332357# Health check for container orchestration
333358HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
0 commit comments