This is an automated email from the ASF dual-hosted git repository.

zfc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-website.git

commit ed2098b4f62c0140a99831ecefa3bcab6f50393f
Author: Zhaofeng Chen <[email protected]>
AuthorDate: Fri Jun 6 01:12:37 2025 +0000

    [Mod] prebuilt api docs and refactor build-env
---
 Dockerfile    | 91 +++++++++++++++++++++++++++++++++++------------------------
 site/Makefile | 62 ++++++++++++++++++----------------------
 2 files changed, 82 insertions(+), 71 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 34a3ecc6f..898215470 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,54 +1,71 @@
-# Stage 1: Install dependencies
-FROM node:16.20.2-bullseye AS deps
+# SGX Docs stage
+FROM teaclave/teaclave-build-ubuntu-1804-sgx-2.14:latest AS sgx-docs
+WORKDIR /app
+COPY sgx-sdk-api-docs /app/sgx-sdk-api-docs
+RUN . "$HOME/.cargo/env" && cd sgx-sdk-api-docs && cargo doc
+RUN mkdir -p /prebuilt_docs && \
+    cp -r sgx-sdk-api-docs/target/doc /prebuilt_docs/sgx-sdk-docs
 
-# Install system dependencies
-RUN apt-get update && apt-get install -y \
-    git \
-    python3 \
-    python3-pip \
-    curl \
-    build-essential \
-    openssh-client \
-    && rm -rf /var/lib/apt/lists/*
-
-# Install Rust toolchain and xargo
-RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && 
\
-    . "$HOME/.cargo/env" && \
-    rustup install nightly-2022-10-22 && \
-    rustup default nightly-2022-10-22 && \
-    cargo install xargo
+# TODO: Add Trustzone Docs stage
 
-ENV PATH="/root/.cargo/bin:${PATH}"
+# Teaclave Docs stage
+FROM teaclave/teaclave-build-ubuntu-2004-sgx-2.17.1:0.2.0 AS teaclave-docs
+WORKDIR /app
 
-# Install Python dependencies including ghp-import
-RUN pip3 install grpcio-tools grpclib pdoc ghp-import
+# Prepare Teaclave Repo
+RUN git clone https://github.com/apache/incubator-teaclave.git teaclave
+RUN cd teaclave && git submodule update --init 
 
-# Set working directory
-WORKDIR /app
+# Build Python SDK docs
+RUN pip3 install grpcio-tools grpclib pdoc
+RUN python3 -m grpc_tools.protoc \
+    --proto_path=teaclave/services/proto/src/proto \
+    --python_out=teaclave/sdk/python \
+    --grpclib_python_out=teaclave/sdk/python \
+    teaclave/services/proto/src/proto/*.proto
+RUN PYTHONPATH=teaclave/sdk/python pdoc teaclave/sdk/python/teaclave.py -o 
/tmp/client-sdk-python-docs
 
-# Copy package files
-COPY site/package*.json site/
+# Build Teaclave docs
+RUN . /opt/sgxsdk/environment && \
+    . /root/.cargo/env && \
+    cd teaclave && \
+    mkdir build && \
+    cd build && \
+    cmake .. && \
+    make doc -j$(nproc)
 
-# Install npm dependencies
+# Copy all docs to prebuilt directory
+RUN mkdir -p /prebuilt_docs/teaclave-docs && \
+    cp -r /tmp/client-sdk-python-docs 
/prebuilt_docs/teaclave-docs/client-sdk-python && \
+    cd teaclave/release/ && \
+    cp -r ./docs/enclave /prebuilt_docs/teaclave-docs/enclave && \
+    cp -r ./docs/app /prebuilt_docs/teaclave-docs/app && \
+    cp -r ./docs/unix /prebuilt_docs/teaclave-docs/client-sdk-rust 
+
+# clean up
+RUN rm -rf teaclave/build
+
+# Dependencies stage
+FROM node:16.20.2-bullseye AS deps
+WORKDIR /app
+COPY site/package*.json site/
 RUN cd site && npm install
 
-# Stage 2: Development environment
-FROM node:16.20.2-bullseye
+# Final stage
+FROM node:16.20.2-bullseye as teaclave-docs-site
 
-# Copy installed dependencies from deps stage
-COPY --from=deps /root/.cargo /root/.cargo
-COPY --from=deps /usr/local/lib/python3.9/dist-packages 
/usr/local/lib/python3.9/dist-packages
 COPY --from=deps /app/site/node_modules /app/site/node_modules
+COPY --from=sgx-docs /prebuilt_docs/sgx-sdk-docs /prebuilt_docs/sgx-sdk-docs
+COPY --from=teaclave-docs /prebuilt_docs/teaclave-docs 
/prebuilt_docs/teaclave-docs
 
-# Set up environment
 ENV PATH="/root/.cargo/bin:${PATH}"
 ENV PYTHONPATH="/usr/local/lib/python3.9/dist-packages:${PYTHONPATH}"
 
-# Set working directory
 WORKDIR /app
-
-# Install VuePress globally
 RUN npm install -g [email protected]
 
-# Create a volume for the build output
-VOLUME ["/app/site/.vuepress/dist"] 
+RUN apt-get update && apt-get install -y \
+    python3 \
+    python3-pip \
+    curl
+RUN pip3 install ghp-import
\ No newline at end of file
diff --git a/site/Makefile b/site/Makefile
index 43af6c468..7ab642a35 100644
--- a/site/Makefile
+++ b/site/Makefile
@@ -8,7 +8,8 @@ site: build
 
 init-repo:
        git clone https://github.com/apache/incubator-teaclave.git teaclave
-       git clone -b v2.0.0-preview 
https://github.com/apache/incubator-teaclave-sgx-sdk.git teaclave-sgx-sdk
+       # v2.0.0-preview branch does not have documents folder, we use master 
branch instead
+       git clone -b master 
https://github.com/apache/incubator-teaclave-sgx-sdk.git teaclave-sgx-sdk
        git clone 
https://github.com/apache/incubator-teaclave-trustzone-sdk.git 
teaclave-trustzone-sdk
 
 check-repo:
@@ -22,51 +23,44 @@ update-repo: check-repo
        cd teaclave-sgx-sdk && git pull
        cd teaclave-trustzone-sdk && git pull
 
-sgx-sdk-api-docs: teaclave-docs
-       cd ../sgx-sdk-api-docs && cargo doc
-       cp -r ../sgx-sdk-api-docs/target/doc .vuepress/dist/api-docs/sgx-sdk
-       @echo "<meta http-equiv=refresh content=0;url=`echo sgx_tstd | cut -d 
'/' -f 2`/index.html>" > .vuepress/dist/api-docs/sgx-sdk/index.html
-
-trustzone-sdk-api-docs: teaclave-docs
-       cd teaclave-trustzone-sdk && ./setup.sh
-       bash -c "cd teaclave-trustzone-sdk && source environment && cd 
optee-utee && xargo doc --target aarch64-unknown-optee-trustzone --no-deps"
-       bash -c "cd teaclave-trustzone-sdk && source environment && cd 
optee-teec && cargo doc --target aarch64-unknown-linux-gnu --no-deps"
-       mkdir -p .vuepress/dist/api-docs/trustzone-sdk
-       cp -r 
teaclave-trustzone-sdk/optee-utee/target/aarch64-unknown-optee-trustzone/doc 
.vuepress/dist/api-docs/trustzone-sdk/optee-utee
-       cp -r 
teaclave-trustzone-sdk/optee-teec/target/aarch64-unknown-linux-gnu/doc 
.vuepress/dist/api-docs/trustzone-sdk/optee-teec
-       @echo "<meta http-equiv=refresh content=0;url=`echo optee_utee | cut -d 
'/' -f 2`/index.html>" > 
.vuepress/dist/api-docs/trustzone-sdk/optee-utee/index.html
-       @echo "<meta http-equiv=refresh content=0;url=`echo optee_teec | cut -d 
'/' -f 2`/index.html>" > 
.vuepress/dist/api-docs/trustzone-sdk/optee-teec/index.html
-
-client-sdk-python-docs: teaclave-docs
-       python3 -m grpc_tools.protoc 
--proto_path=teaclave/services/proto/src/proto --python_out=teaclave/sdk/python 
--grpclib_python_out=teaclave/sdk/python 
teaclave/services/proto/src/proto/*.proto
-       PYTHONPATH=teaclave/sdk/python pdoc teaclave/sdk/python/teaclave.py -o 
.vuepress/dist/api-docs/client-sdk-python
+sgx-sdk-api-docs: site-build
+       mkdir -p .vuepress/dist/api-docs/sgx-sdk-docs
+       cp -r /prebuilt_docs/sgx-sdk-docs/* 
.vuepress/dist/api-docs/sgx-sdk-docs/
+       @echo "<meta http-equiv=refresh content=0;url=`echo sgx_tstd | cut -d 
'/' -f 2`/index.html>" > .vuepress/dist/api-docs/sgx-sdk-docs/index.html
+
+trustzone-sdk-api-docs: site-build
+       @echo "Trustzone SDK API docs not supported yet"
+
+client-sdk-python-docs: site-build
+       cp -r /prebuilt_docs/teaclave-docs/client-sdk-python 
.vuepress/dist/api-docs/client-sdk-python
        @echo "<meta http-equiv=refresh content=0;url=python/teaclave.html>" > 
.vuepress/dist/api-docs/client-sdk-python/index.html
 
-client-sdk-rust-docs: teaclave-docs
-       (cd teaclave && git submodule update --init third_party/rust-sgx-sdk)
-       rustup default nightly-2022-10-22
-       cargo doc --no-deps --manifest-path teaclave/sdk/rust/Cargo.toml
-       cp -r teaclave/sdk/rust/target/doc 
.vuepress/dist/api-docs/client-sdk-rust
-       @rm -rf teaclave/third_party/rust-sgx-sdk
+client-sdk-rust-docs: site-build
+       cp -r /prebuilt_docs/teaclave-docs/client-sdk-rust 
.vuepress/dist/api-docs/client-sdk-rust
        @echo "<meta http-equiv=refresh content=0;url=`echo teaclave_client_sdk 
| cut -d '/' -f 2`/index.html>" > 
.vuepress/dist/api-docs/client-sdk-rust/index.html
 
-crate-docs:
-       cp ${TEACLAVE_TARGET_DIR}/docs/enclave 
.vuepress/dist/api-docs/crates-enclave -r
-       cp ${TEACLAVE_TARGET_DIR}/docs/app .vuepress/dist/api-docs/crates-app -r
+teaclave-crates-docs: site-build
+       cp -r /prebuilt_docs/teaclave-docs/enclave 
.vuepress/dist/api-docs/crates-enclave 
+       cp -r /prebuilt_docs/teaclave-docs/app 
.vuepress/dist/api-docs/crates-app
+
+teaclave-docs: teaclave-crates-docs client-sdk-python-docs client-sdk-rust-docs
 
-teaclave-docs: update-repo
+site-build: update-repo
        vuepress build
 
-dev: update-repo
-       cd teaclave-trustzone-sdk
+dev:
        vuepress dev
 
 preview:
        cd .vuepress/dist && python3 -m http.server
 
-build: teaclave-docs sgx-sdk-api-docs trustzone-sdk-api-docs 
client-sdk-python-docs client-sdk-rust-docs crate-docs
+build: teaclave-docs sgx-sdk-api-docs trustzone-sdk-api-docs 
        cp ../.asf.yaml .vuepress/dist
 
-clean:
-       rm -rf .vuepress/dist teaclave teaclave-sgx-sdk teaclave-trustzone-sdk
+clean-repo:
+       rm -rf teaclave
+       rm -rf teaclave-sgx-sdk
+       rm -rf teaclave-trustzone-sdk
 
+clean: clean-repo
+       rm -rf .vuepress/dist 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to