fixed docker build issue

This commit is contained in:
2026-08-07 10:50:04 +05:30
parent 10ae1c0539
commit 5c559b2a0f
4 changed files with 31 additions and 6 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ services:
image: pdf-engine-frontend:dev
container_name: pdf-engine-frontend
environment:
VITE_GATEWAY_URL: http://localhost:8765
VITE_GATEWAY_URL: https://pdfapi-dev.maskantech.in
ports:
- "5173:5173"
volumes:
+1 -1
View File
@@ -1 +1 @@
VITE_GATEWAY_URL=http://127.0.0.1:8765
VITE_GATEWAY_URL=https://pdfapi-dev.maskantech.in
+4 -2
View File
@@ -8,7 +8,6 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
cmake \
ninja-build \
pkg-config \
git \
@@ -35,6 +34,9 @@ RUN git clone https://github.com/microsoft/vcpkg.git /opt/vcpkg \
&& /opt/vcpkg/bootstrap-vcpkg.sh -disableMetrics
ENV VCPKG_ROOT=/opt/vcpkg
# Ensure a recent CMake is available (system cmake in slim images can be too old for vcpkg)
RUN python -m pip install --upgrade pip cmake
# Cache vcpkg dependencies in a separate layer
COPY vcpkg.json ./
RUN --mount=type=cache,target=/root/.cache \
@@ -51,7 +53,7 @@ ENV PATH="/opt/depot_tools:${PATH}"
# Build PDFium for Linux (heavily cached, keeping the huge source tree out of the image layer)
COPY third_party/pdfium/ ./third_party/pdfium/
RUN --mount=type=cache,target=/build/third_party/pdfium/checkout \
./third_party/pdfium/build_pdfium.sh
sed -i 's/\r$//' ./third_party/pdfium/build_pdfium.sh && bash ./third_party/pdfium/build_pdfium.sh
# Copy everything needed for the engine and bindings build
COPY CMakeLists.txt CMakePresets.json ./
+25 -2
View File
@@ -34,6 +34,26 @@ DEPOT_TOOLS_DIR="${BUILD_ROOT}/depot_tools"
CHECKOUT_DIR="${BUILD_ROOT}/checkout"
echo ">> Build root: ${BUILD_ROOT}"
# Simple retry helper for transient network/git errors
retry() {
local -r -i max_attempts=${MAX_ATTEMPTS:-5}
local -r -i initial_sleep=${INITIAL_SLEEP:-5}
local -i attempt=1
local sleep_time=$initial_sleep
while true; do
if "$@"; then
return 0
fi
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Command failed after $attempt attempts: $*" >&2
return 1
fi
echo "Command failed (attempt $attempt/$max_attempts). Retrying in ${sleep_time}s..." >&2
sleep "$sleep_time"
attempt=$((attempt+1))
sleep_time=$((sleep_time*2))
done
}
# --- 1. Read and validate the pinned revision -------------------------------
PDFIUM_REPO="$(grep -E '^PDFIUM_REPO=' "${PINNED_FILE}" | cut -d= -f2- | tr -d '\r')"
PDFIUM_COMMIT="$(grep -E '^PDFIUM_COMMIT=' "${PINNED_FILE}" | cut -d= -f2- | tr -d '\r')"
@@ -82,11 +102,14 @@ git fetch origin "${PDFIUM_COMMIT}"
git checkout --detach "${PDFIUM_COMMIT}"
gclient sync --no-history --shallow --reset --force -D
# --- 5. GN args: static, standalone, monolithic, embed-friendly -------------
echo ">> gclient sync (pulls several GB; slow)"
retry gclient sync --no-history --shallow --reset --force
mkdir -p out/Release
cp "${SCRIPT_DIR}/args.gn" out/Release/args.gn
# --- 6. Generate + build ----------------------------------------------------
git fetch origin "${PDFIUM_COMMIT}"
retry git checkout --detach "${PDFIUM_COMMIT}"
retry gclient sync --no-history --shallow --reset --force -D
echo ">> gn gen + ninja"
gn gen out/Release
ninja -C out/Release pdfium