1+ 
2+ FROM  debian:bookworm-slim AS base 
3+ 
4+ #  Build Arguments
5+ ARG  ARCH=linux-aarch64
6+ ARG  SDK_VERSION=0.800.3
7+ ARG  JAVA_VERSION=17
8+ ARG  SCANBOT_LICENSE="" 
9+ 
10+ #  Environment Variables
11+ ENV  ARCH=${ARCH} \
12+     SDK_VERSION=${SDK_VERSION} \
13+     JAVA_VERSION=${JAVA_VERSION} \
14+     VENV_PATH=/opt/venv \
15+     SDK_BASE_URL="https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv"  \
16+     SCANBOT_LICENSE=${SCANBOT_LICENSE}
17+ 
18+ #  Install system dependencies
19+ RUN  apt-get update && apt-get install -y --no-install-recommends \
20+     #  Build tools
21+     build-essential \
22+     cmake \
23+     make \
24+     #  Languages  
25+     openjdk-${JAVA_VERSION}-jdk \
26+     python3 \
27+     python3-venv \
28+     python3-pip \
29+     #  Utilities
30+     curl \
31+     git \
32+     ca-certificates \
33+     #  Add Node.js repository and install
34+     && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
35+     && apt-get install -y nodejs \
36+     && apt-get clean && rm -rf /var/lib/apt/lists/*
37+ 
38+ ENV  JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64 \
39+     PATH="/usr/lib/jvm/java-17-openjdk-arm64/bin:/opt/venv/bin:${PATH}" 
40+ 
41+ #  Verify installation and create architecture-agnostic symlink as fallback
42+ RUN  set -eux; \
43+     if [ ! -d "$JAVA_HOME"  ]; then \
44+         JAVA_HOME="$(dirname $(dirname $(readlink -f $(which java))))" ; \
45+     fi; \
46+     ln -sf "$JAVA_HOME"  /usr/local/java; \
47+     java -version; \
48+     javac -version
49+ 
50+ #  Set up Python virtual environment
51+ RUN  python3 -m venv $VENV_PATH \
52+     && pip install --upgrade pip setuptools wheel \
53+     && pip install opencv-python
54+ 
55+ #  Install Python SDK
56+ RUN  if [ "${ARCH}"  = "linux-aarch64"  ]; then \
57+         PYTHON_ARCH="linux_aarch64" ; \
58+     else \
59+         PYTHON_ARCH="linux_x86_64" ; \
60+     fi && \
61+     pip install "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-py3-none-${PYTHON_ARCH}.whl"  && \
62+     echo "Python SDK installed successfully" 
63+ 
64+ #  Set working directory and copy source code
65+ WORKDIR  /workspaces/scanbot-sdk-example-linux
66+ COPY  . .
67+ 
68+ #  Download and install all remaining SDKs in optimal locations
69+ RUN  echo "Installing Node.js, Java, and C SDKs for architecture: ${ARCH}"  && \
70+     #  Download platform-dependent SDKs (Java and C)
71+     curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${ARCH}.jar"  && \
72+     curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${ARCH}.tar.gz"  && \
73+     #  Install Node.js SDK
74+     cd examples/nodejs && \
75+     npm install "${SDK_BASE_URL}${SDK_VERSION}/nodejs-scanbotsdk-${SDK_VERSION}.tgz"  && \
76+     cd /workspaces/scanbot-sdk-example-linux && \
77+     #  Install Java SDK  
78+     mkdir -p examples/java/build/libs && \
79+     cp "scanbotsdk-${SDK_VERSION}-${ARCH}.jar"  examples/java/build/libs/scanbotsdk.jar && \
80+     #  Install C SDK
81+     mkdir -p examples/c/build/scanbotsdk && \
82+     tar -xzf "scanbotsdk-${SDK_VERSION}-${ARCH}.tar.gz"  -C examples/c/build/scanbotsdk --strip-components=1 && \
83+     #  Clean up downloads
84+     rm -f *.tar.gz *.jar && \
85+     echo "All SDKs installed successfully" 
86+ 
87+ #  Copy test scripts
88+ COPY  test-scripts/ /tests/
89+ RUN  chmod +x /tests/*.sh
90+ 
91+ #  Base verification - ensure all SDKs can be imported/built  
92+ RUN  echo "=== SDK Integration Verification ==="  \
93+     && python3 -c "import scanbotsdk; print('Python SDK: OK')"  \
94+     && cd examples/nodejs && npm install && node -e "console.log('Node.js SDK:', require('scanbotsdk') ? 'OK' : 'FAIL')"  \
95+     && cd /workspaces/scanbot-sdk-example-linux/examples/java && ./gradlew build --no-daemon && echo "Java SDK: OK"  \
96+     && cd /workspaces/scanbot-sdk-example-linux/examples/c && mkdir -p build && cd build && cmake -DSCANBOTSDK_VERSION=${SDK_VERSION} .. && make && echo "C SDK: OK" 
97+ 
98+ #  SDK Verification Stage
99+ FROM  base AS sdk-verification
100+ RUN  echo "=== Comprehensive SDK Verification ==="  \
101+     && python3 -c "import scanbotsdk; print('Python SDK: Verified')"  \
102+     && cd examples/nodejs && npm install && node -e "const sdk = require('scanbotsdk'); console.log('Node.js SDK: Verified')"  \
103+     && cd /workspaces/scanbot-sdk-example-linux/examples/java && ./gradlew check --no-daemon && echo "Java SDK: Verified"  \
104+     && cd /workspaces/scanbot-sdk-example-linux/examples/c && cd build && echo "C SDK: Verified" 
105+ 
106+ #  Python Tests Stage
107+ FROM  sdk-verification AS python-tests
108+ RUN  echo "=== Running Python Command Tests ==="  \
109+     && /tests/test-python.sh
110+ 
111+ #  Java Tests Stage
112+ FROM  sdk-verification AS java-tests
113+ RUN  echo "=== Running Java Command Tests ==="  \
114+     && /tests/test-java.sh
115+ 
116+ #  Node.js Tests Stage
117+ FROM  sdk-verification AS nodejs-tests
118+ RUN  echo "=== Running Node.js Command Tests ==="  \
119+     && /tests/test-nodejs.sh
120+ 
121+ #  C Tests Stage
122+ FROM  sdk-verification AS c-tests
123+ RUN  echo "=== Running C Command Tests ==="  \
124+     && /tests/test-c.sh
125+ 
126+ #  All Tests Stage
127+ FROM  sdk-verification AS all-tests
128+ RUN  echo "=== Running Complete Test Suite ==="  \
129+     && /tests/run-all-tests.sh \
130+     && echo "Python import and commands verified"  \
131+     && echo "Java compilation and commands verified"  \
132+     && echo "Node.js compilation and commands verified"  \
133+     && echo "C compilation and commands verified" 
0 commit comments