-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
136 lines (108 loc) · 4.63 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
##############################################################################
# #
# Demo base #
# #
##############################################################################
FROM initc3/linux-sgx:2.16-ubuntu20.04 AS demo-base
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED 1
RUN apt-get update && apt-get install -y \
curl \
git \
python3.9 \
python3.9-dev \
python3-pip \
python-is-python3 \
sudo \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
# install nix
ARG UID=1000
ARG GID=1000
RUN groupadd --gid $GID --non-unique photon \
&& useradd --create-home --uid $UID --gid $GID --non-unique --shell /bin/bash photon \
&& usermod --append --groups sudo photon \
&& echo "photon ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/photon \
&& mkdir -p /etc/nix \
&& echo 'sandbox = false' > /etc/nix/nix.conf
ENV USER photon
USER photon
WORKDIR /home/photon
RUN curl -L https://nixos.org/nix/install | sh
RUN . /home/photon/.nix-profile/etc/profile.d/nix.sh && \
nix-channel --add https://nixos.org/channels/nixos-22.11 nixpkgs && \
nix-channel --update
ENV NIX_PROFILES "/nix/var/nix/profiles/default /home/photon/.nix-profile"
ENV NIX_PATH /home/photon/.nix-defexpr/channels
ENV NIX_SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt
ENV PATH /home/photon/.nix-profile/bin:$PATH
RUN pip install --user cryptography ipython requests pyyaml ipdb blessings colorama
RUN set -ex; \
\
cd /tmp; \
git clone --recurse-submodules https://github.com/sbellem/auditee.git; \
pip install --user auditee/
ENV PATH="/home/photon/.local/bin:${PATH}"
##############################################################################
# #
# Build enclave (trusted) #
# #
##############################################################################
FROM nixpkgs/nix AS build-enclave
WORKDIR /usr/src
COPY common /usr/src/common
COPY enclave /usr/src/enclave
COPY interface /usr/src/interface
COPY makefile /usr/src/makefile
COPY nix /usr/src/nix
COPY default.nix /usr/src/default.nix
RUN nix-build
##############################################################################
# #
# Build app (untrusted) #
# #
##############################################################################
FROM initc3/linux-sgx:2.16-ubuntu20.04 AS build-app
RUN apt-get update && apt-get install -y \
autotools-dev \
automake \
xxd \
iputils-ping \
libssl-dev \
vim \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/sgxiot
ENV SGX_SDK /opt/sgxsdk
ENV PATH $PATH:$SGX_SDK/bin:$SGX_SDK/bin/x64
ENV PKG_CONFIG_PATH $SGX_SDK/pkgconfig
ENV LD_LIBRARY_PATH $SGX_SDK/sdk_libs
COPY . .
ARG SGX_MODE=HW
ENV SGX_MODE $SGX_MODE
ARG SGX_DEBUG=1
ENV SGX_DEBUG $SGX_DEBUG
RUN make untrusted
##############################################################################
# #
# Demo runtime #
# #
##############################################################################
FROM demo-base
RUN mkdir /home/photon/sgxiot
WORKDIR /home/photon/sgxiot
COPY --chown=photon:photon common common
COPY --chown=photon:photon enclave enclave
COPY --chown=photon:photon interface interface
COPY --chown=photon:photon nix nix
COPY --chown=photon:photon .auditee.yml \
default.nix \
makefile \
nix.Dockerfile \
run_demo_sgxra.sh \
Sensor_Data \
verify.py \
./
COPY --from=build-enclave --chown=photon:photon \
/usr/src/result/bin/enclave.signed.so enclave/enclave.signed.so
COPY --from=build-app --chown=photon:photon /usr/src/sgxiot/app app