1+
2+ # Copyright (c) 2022 Intel Corporation
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+
16+ # https://github.com/oscarlab/graphene/blob/master/Tools/gsc/images/graphene_aks.latest.dockerfile
17+ FROM openanolis/anolisos:8.4-x86_64 AS Anolisos
18+
19+ ENV INSTALL_PREFIX=/usr/local
20+ ENV LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib:${INSTALL_PREFIX}/lib64:${LD_LIBRARY_PATH}
21+ ENV PATH=${INSTALL_PREFIX}/bin:${LD_LIBRARY_PATH}:${PATH}
22+ # Add steps here to set up dependencies
23+ RUN yum -y install \
24+ openssl-devel \
25+ libcurl-devel \
26+ protobuf-devel \
27+ yum-utils.noarch \
28+ python3 \
29+ wget
30+
31+ # Intel SGX
32+ RUN mkdir /opt/intel && cd /opt/intel \
33+ && wget https://mirrors.openanolis.cn/inclavare-containers/bin/anolis8.4/sgx-2.15.1/sgx_rpm_local_repo.tar.gz \
34+ && sha256sum sgx_rpm_local_repo.tar.gz \
35+ && tar xvf sgx_rpm_local_repo.tar.gz \
36+ && yum-config-manager --add-repo file:///opt/intel/sgx_rpm_local_repo \
37+ && yum -y --nogpgcheck install libsgx-urts libsgx-launch libsgx-epid libsgx-quote-ex libsgx-dcap-ql libsgx-uae-service libsgx-dcap-quote-verify-devel
38+ && yum -y groupinstall 'Development Tools'
39+
40+ # COPY patches/libsgx_dcap_quoteverify.so /usr/lib64/
41+ RUN yum -y install --nogpgcheck sgx-dcap-pccs libsgx-dcap-default-qpl
42+
43+ # Gramine
44+ ENV GRAMINEDIR=/gramine
45+ ENV SGX_DCAP_VERSION=DCAP_1.11
46+ ENV GRAMINE_VERSION=v1.2
47+ ENV ISGX_DRIVER_PATH=${GRAMINEDIR}/driver
48+ ENV PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/
49+ ENV LC_ALL=C.UTF-8 LANG=C.UTF-8
50+ ENV WERROR=1
51+ ENV SGX=1
52+ ENV GRAMINE_PKGLIBDIR=/usr/local/lib64/gramine
53+ ENV ARCH_LIBDIR=/lib64
54+
55+ RUN yum -y install gawk bison python3-click python3-jinja2 golang ninja-build
56+ RUN yum -y install openssl-devel protobuf-c-devel python3-protobuf protobuf-c-compiler
57+ RUN yum -y install gmp-devel mpfr-devel libmpc-devel isl-devel nasm python3-devel mailcap
58+ # install gramine
59+ RUN ln -s /usr/bin/python3 /usr/bin/python \
60+ && python3 -m pip install --upgrade pip \
61+ && python3 -m pip install toml meson wheel cryptography paramiko \
62+ && git clone https://github.com/gramineproject/gramine.git ${GRAMINEDIR} \
63+ && cd ${GRAMINEDIR} \
64+ && git checkout ${GRAMINE_VERSION}
65+
66+ RUN git clone https://github.com/intel/SGXDataCenterAttestationPrimitives.git ${ISGX_DRIVER_PATH} \
67+ && cd ${ISGX_DRIVER_PATH} \
68+ && git checkout ${SGX_DCAP_VERSION}
69+
70+ ENV LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib:${INSTALL_PREFIX}/lib64:${LD_LIBRARY_PATH}
71+ RUN cd ${GRAMINEDIR} \
72+ && LD_LIBRARY_PATH="" meson setup build/ --buildtype=debug -Dprefix=${INSTALL_PREFIX} -Ddirect=enabled -Dsgx=enabled -Ddcap=enabled -Dsgx_driver=dcap1.10 -Dsgx_driver_include_path=${ISGX_DRIVER_PATH}/driver/linux/include \
73+ && LD_LIBRARY_PATH="" ninja -C build/ \
74+ && LD_LIBRARY_PATH="" ninja -C build/ install
75+ RUN gramine-sgx-gen-private-key
76+
77+ FROM Anolisos AS Psi_tensorflow
78+ # Install mbedtls
79+ RUN cd ${GRAMINEDIR}/build/subprojects/mbedtls-mbedtls* \
80+ && cp -r *_gramine.a ${INSTALL_PREFIX}/lib \
81+ && cd ${GRAMINEDIR}/subprojects/mbedtls-mbedtls*/mbedtls-mbedtls* \
82+ && cp -r include/mbedtls ${INSTALL_PREFIX}/include
83+
84+ # Install cJSON
85+ RUN cd ${GRAMINEDIR}/subprojects/cJSON*/ \
86+ && make static \
87+ && cp -r *.a ${INSTALL_PREFIX}/lib \
88+ && mkdir -p ${INSTALL_PREFIX}/include/cjson \
89+ && cp -r *.h ${INSTALL_PREFIX}/include/cjson
90+
91+ RUN echo "enabled=0" > /etc/default/apport
92+ RUN echo "exit 0" > /usr/sbin/policy-rc.d
93+
94+ # Clean tmp files
95+ RUN yum -y clean all && rm -rf /var/cache
96+
97+ COPY configs /
98+
99+ # Workspace
100+ ENV WORK_SPACE_PATH=${GRAMINEDIR}
101+ WORKDIR ${WORK_SPACE_PATH}
0 commit comments