-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
183 lines (153 loc) · 6.2 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
### Plain stage to download basic packages ###
FROM ubuntu:22.04 AS stage-base-plain
MAINTAINER Jason Teutsch
SHELL ["/bin/bash", "-c"]
RUN apt-get update && apt-get install --no-install-recommends -y curl wget git \
python3 xz-utils ca-certificates
# && rm -rf /var/lib/apt/lists/*
### Base stage to download common packages ###
FROM stage-base-plain AS stage-base-01
# Get packages list and user utilities
RUN apt-get install --no-install-recommends -y \
# User utilities
jq nano tmux vim curl \
# stage-Emscripten packages
make cmake g++ \
# stage-LLVM packages
ninja-build \
# stage-ocaml-offchain interpreter
libffi-dev libzarith-ocaml-dev m4 opam pkg-config zlib1g-dev \
# Install Toolchain libraries
autoconf bison flex libtool lzip \
wabt python3-pip python3-venv \
&& rm -rf /var/lib/apt/lists/*
################################################################################
######## The following stages run in sequence from stage-base-01. ##############
################################################################################
# Install WASI-SDK using Wasienv components
FROM stage-base-01 AS stage-base-02
ENV PATH="${PATH}:/root/.local/bin"
RUN curl https://raw.githubusercontent.com/wasienv/wasienv/master/install.sh | sh || echo ":(("
RUN wasienv install-sdk unstable
# Install Node package manager
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash \
&& source ~/.nvm/nvm.sh \
&& nvm install 16.16.0
# Add support for Rust tasks
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& source $HOME/.cargo/env \
&& rustup install 1.63.0 \
&& rustup default 1.63.0 \
&& rustup target add wasm32-unknown-unknown \
&& rustup target add wasm32-wasi
# Installing correct versions of OCaml compilers
RUN opam init --disable-sandboxing -y git+https://github.com/ocaml/opam-repository \
&& opam update \
&& opam switch create 4.05.0
RUN eval `opam config env` \
&& opam update \
&& opam install cryptokit yojson ocamlbuild -y
RUN opam switch create 4.14.0
RUN opam switch 4.14.0 \
&& opam install wasm ocamlbuild -y \
&& opam switch 4.05.0
#################################################################################
############### The following stages run in parallel ############################
#################################################################################
# Install Solidity
FROM stage-base-plain AS stage-Solidity
RUN cd bin \
&& wget https://github.com/ethereum/solidity/releases/download/v0.5.17/solc-static-linux \
&& mv solc-static-linux solc \
&& chmod 744 solc
# Install Geth
FROM stage-base-plain AS stage-Geth
RUN wget https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.13.14-2bd6bd01.tar.gz \
&& tar xf geth*tar.gz \
&& rm geth*tar.gz \
&& cd geth*
# Install Consensus
FROM stage-base-plain AS stage-Prysm
RUN mkdir ethereum \
&& cd ethereum \
&& mkdir consensus \
&& cd consensus \
&& mkdir prysm \
&& cd prysm \
&& curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh \
&& chmod 755 prysm.sh \
&& wget https://github.com/eth-clients/eth2-networks/blob/master/shared/mainnet/genesis.ssz \
&& export PRYSM_ALLOW_UNVERIFIED_BINARIES=1 \
&& ./prysm.sh beacon-chain generate-auth-secret \
&& cp jwt.hex .. \
&& cd .. \
&& chmod 0444 jwt.hex
# Install IPFS
FROM stage-base-plain AS stage-IPFS
RUN wget https://dist.ipfs.io/go-ipfs/v0.7.0/go-ipfs_v0.7.0_linux-amd64.tar.gz \
&& tar xf go-ipfs_v0.7.0_linux-amd64.tar.gz \
&& cd go-ipfs \
&& ./install.sh
###############################################################################
###### Final Image is composed from previous stages + Sample Tasks ############
###############################################################################
# Final Image
FROM stage-base-02 as final-image
COPY --from=stage-Solidity /bin/solc /bin/
COPY --from=stage-Geth /geth-alltools-linux-amd64-1.13.14-2bd6bd01/geth /bin/
COPY --from=stage-Geth /geth-alltools-linux-amd64-1.13.14-2bd6bd01/clef /bin/
COPY --from=stage-Prysm /ethereum /ethereum
COPY --from=stage-IPFS /usr/local/bin/ipfs /usr/local/bin/
COPY . truebit-eth/
ARG URL_TRUEBIT_OS=https://downloads.truebit.io/truebit-linux
ADD $URL_TRUEBIT_OS truebit-eth/truebit-os
# Install ocaml-offchain interpreter
RUN eval `opam config env` \
&& cd /truebit-eth/ocaml-offchain/interpreter \
&& make
# Install bulk memory ops handler pass
RUN opam switch 4.14.0 \
&& eval `opam config env` \
&& cd /truebit-eth/memory-ops \
&& rm -f ops.native \
&& ocamlbuild -package wasm ops.native \
&& rm -rf ~/.opam
# Copy the implementation of bulk memory ops
RUN cd /truebit-eth/memory-ops \
&& wat2wasm impl.wat -o bulkmemory.wasm \
&& cp bulkmemory.wasm ../wasm-module-wrapper
# Install Wasm module wrapper and dependencies for deploying sample tasks
RUN source ~/.nvm/nvm.sh \
&& cd /truebit-eth/wasm-module-wrapper \
&& ln -s /truebit-eth/wasm-module-wrapper /root/wasm-module-wrapper \
&& cd /truebit-eth/wasm-client \
&& ln -s /truebit-eth/ocaml-offchain \
&& cd /truebit-eth \
&& apt-get update && apt-get install -y openssh-client \
&& npm ci
# Install Toolchain libraries
RUN cd /truebit-eth/wasm-ports \
&& sh openssl.sh
# Move initialization scripts for compiling, network, and authentication.
RUN chmod 755 /truebit-eth/truebit-os \
&& mv /truebit-eth/goerli.sh / \
&& mv /truebit-eth/mainnet.sh /
# Compile C/C++ sample tasks
RUN ipfs init \
&& source ~/.nvm/nvm.sh \
&& ( ipfs daemon & ) \
&& cd /truebit-eth/wasm-ports/samples/chess \
&& sh compile.sh \
&& cd ../scrypt \
&& sh compile.sh \
&& cd /truebit-eth/data \
&& sh compile.sh \
&& rm -r /root/.ipfs
# Compile Rust sample task
RUN ipfs init \
### Initialize
&& cd / \
&& rm -r boot home media mnt opt srv \
&& echo -e '\n# Set up Emscripten\nsource /emsdk/emsdk_env.sh &>/dev/null\n\n# Create Geth keystore directories\nmkdir -p ~/.ethereum/keystore\nmkdir -p ~/.ethereum/goerli/keystore' >> ~/.bashrc
# Open IPFS and blockchain ports
EXPOSE 4001 8080 8545 8546 30303