From 8d23ccad5a79496464e60be4f61a5d17246061a8 Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 6 Dec 2023 23:20:57 +0400 Subject: [PATCH] Fix deb workflow & regular workflow - split deb into separate dockerfile, switch node.Dockerfile to 2.19-jammy instead of 2.19-bionic --- .github/workflows/build-deb.yml | 2 +- docker/deb.Dockerfile | 69 +++++++++++++++++++++++++++++++++ docker/node.Dockerfile | 30 +------------- 3 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 docker/deb.Dockerfile diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index d2e1dd5b..14c5eb8a 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -31,7 +31,7 @@ jobs: - name: Build .deb Package Image uses: docker/build-push-action@v4 with: - file: ./docker/node.Dockerfile + file: ./docker/deb.Dockerfile context: . load: true tags: deb_build diff --git a/docker/deb.Dockerfile b/docker/deb.Dockerfile new file mode 100644 index 00000000..a32c0646 --- /dev/null +++ b/docker/deb.Dockerfile @@ -0,0 +1,69 @@ +############ Install Intel SGX SDK & SGX PSW +FROM ghcr.io/sigmagmbh/sgx:2.19-bionic as base +RUN wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | apt-key add - +RUN apt-get update + + +############ Compilation base +FROM base as compile-base + +RUN apt-get install -y protobuf-compiler curl + +# Install rust +ENV PATH="/usr/local/go/bin:/go/bin:/root/.cargo/bin:${PATH}" +ENV GOROOT=/usr/local/go +ENV GOPATH=/go/ + +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y > /dev/null 2>&1 +RUN cargo install protobuf-codegen --version "2.8.1" -f + +# Install golang +ADD https://go.dev/dl/go1.19.linux-amd64.tar.gz go.linux-amd64.tar.gz +RUN tar -C /usr/local -xzf go.linux-amd64.tar.gz && rm go.linux-amd64.tar.gz +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \ + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest > /dev/null 2>&1 + + + +############ Compile enclave & chain +FROM compile-base as compile-chain + +RUN apt-get install -y automake autoconf build-essential libtool git + +ARG SGX_MODE=HW +ENV SGX_MODE=${SGX_MODE} +ENV SGX_SDK="/opt/intel/sgxsdk" +ENV PATH="${PATH}:${SGX_SDK}/bin:${SGX_SDK}/bin/x64" +ENV PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${SGX_SDK}/pkgconfig" +ENV LD_LIBRARY_PATH="/opt/intel/sgxsdk/sdk_libs:${LD_LIBRARY_PATH}" + +COPY . /root/chain +WORKDIR /root/chain +RUN make build + + +############ Node binary for deb package +FROM compile-base as build-deb + +ARG BUILD_VERSION="v1.0.1" +ENV VERSION=${BUILD_VERSION} +ARG DEB_BIN_DIR=/usr/local/bin +ENV DEB_BIN_DIR=${DEB_BIN_DIR} +ARG DEB_LIB_DIR=/usr/lib +ENV DEB_LIB_DIR=${DEB_LIB_DIR} +ARG ENCLAVE_HOME=${DEB_LIB_DIR} +ARG ENCLAVE_HOME=${ENCLAVE_HOME} + +WORKDIR /root + +# Copy over binaries from the build-env +COPY --from=compile-chain /root/chain/build/swisstronikd swisstronikd +COPY --from=compile-chain /root/.swisstronik-enclave /usr/lib/.swisstronik-enclave +COPY --from=compile-chain /root/chain/go-sgxvm/internal/api/libsgx_wrapper.x86_64.so /usr/lib/.swisstronik-enclave/libsgx_wrapper.x86_64.so + +COPY ./deb ./deb +COPY ./scripts/build_deb.sh . + +RUN chmod +x build_deb.sh + +CMD ["/bin/bash", "build_deb.sh"] diff --git a/docker/node.Dockerfile b/docker/node.Dockerfile index ddf6dd2c..47acf647 100644 --- a/docker/node.Dockerfile +++ b/docker/node.Dockerfile @@ -1,5 +1,5 @@ ############ Install Intel SGX SDK & SGX PSW -FROM ghcr.io/sigmagmbh/sgx:2.19-bionic as base +FROM ghcr.io/sigmagmbh/sgx:2.19-jammy as base RUN wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | apt-key add - RUN apt-get update @@ -41,34 +41,6 @@ COPY . /root/chain WORKDIR /root/chain RUN make build - -############ Node binary for deb package -FROM compile-base as build-deb - -ARG BUILD_VERSION="v1.0.1" -ENV VERSION=${BUILD_VERSION} -ARG DEB_BIN_DIR=/usr/local/bin -ENV DEB_BIN_DIR=${DEB_BIN_DIR} -ARG DEB_LIB_DIR=/usr/lib -ENV DEB_LIB_DIR=${DEB_LIB_DIR} -ARG ENCLAVE_HOME=${DEB_LIB_DIR} -ARG ENCLAVE_HOME=${ENCLAVE_HOME} - -WORKDIR /root - -# Copy over binaries from the build-env -COPY --from=compile-chain /root/chain/build/swisstronikd swisstronikd -COPY --from=compile-chain /root/.swisstronik-enclave /usr/lib/.swisstronik-enclave -COPY --from=compile-chain /root/chain/go-sgxvm/internal/api/libsgx_wrapper.x86_64.so /usr/lib/.swisstronik-enclave/libsgx_wrapper.x86_64.so - -COPY ./deb ./deb -COPY ./scripts/build_deb.sh . - -RUN chmod +x build_deb.sh - -CMD ["/bin/bash", "build_deb.sh"] - - ############ Node binary in Hardware Mode FROM base as hw-node