-
Notifications
You must be signed in to change notification settings - Fork 538
/
Dockerfile-toolchain
140 lines (111 loc) · 4.95 KB
/
Dockerfile-toolchain
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
FROM ocaml/opam2:debian-9-ocaml-4.08
# if updated, also change in Dockerfile
ARG OCAML_VERSION=4.07.1
# location of repo used for pins and external package commits
ARG CODA_DIR=/coda
# location of external packages
ARG EXTERNAL_PKG_DIR=$CODA_DIR/src/external
# don't keep sources, to force reinstall of pinned packages from Coda sources
# and to keep Docker image reasonable size
ARG OPAMKEEPBUILDDIR=false
ARG OPAMREUSEBUILDDIR=false
# OS package dependencies
RUN sudo apt-get update && sudo apt-get install --yes \
cmake \
jq \
libboost-dev \
libboost-program-options-dev \
libffi-dev \
libgmp-dev \
libgmp3-dev \
libjemalloc-dev \
libpq-dev \
libprocps-dev \
libsodium-dev \
libssl-dev \
lsb \
m4 \
nodejs \
pandoc \
patchelf \
python \
perl \
pkg-config \
python-jinja2 \
python-pip \
python3-pip \
rubygems \
zlib1g-dev \
libbz2-dev
RUN sudo pip install awscli readchar
RUN sudo pip3 install sexpdata
RUN sudo gem install deb-s3
RUN VER="19.03.4" && \
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz && \
tar -xz -C /tmp -f /tmp/docker-$VER.tgz && \
sudo mv /tmp/docker/* /usr/bin
# Google Cloud tools
RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
sudo apt-get update -y && sudo apt-get install google-cloud-sdk -y
# Source copy of rocksdb
RUN sudo git clone https://github.com/facebook/rocksdb -b v5.17.2 /rocksdb
# This builds and installs just the static lib for us
RUN cd /rocksdb && sudo make static_lib PORTABLE=1 -j$(nproc) && sudo cp librocksdb.a /usr/local/lib/librocksdb_coda.a && sudo rm -rf /rocksdb && sudo strip -S /usr/local/lib/librocksdb_coda.a
# clone Coda repo to pin external package and save their commits
RUN sudo git clone https://github.com/CodaProtocol/coda $CODA_DIR
# use HTTPS git clone for submodules
RUN cd $CODA_DIR && sudo sed --in-place s+git@github.com:+https://github.com/+g .gitmodules
# init submodules for pinning
RUN cd $CODA_DIR && sudo git submodule update --init --recursive
# save submodule commits
RUN for pkg in async_kernel digestif graphql_ppx ocaml-extlib rpc_parallel ; do \
# remove leading "-" indicating uninitialized
cd $CODA_DIR && sudo bash -c "git submodule status src/external/$pkg | awk '{print \$1}' | sed s/-// > ~opam/opam-repository/$pkg.commit" ; \
done
# save log commits for ocaml-sodium, coda_base58, which are not submodules
RUN for pkg in ocaml-sodium coda_base58 ; do \
cd $CODA_DIR && sudo bash -c "git log --format=oneline -n 1 src/external/$pkg | awk '{print \$1}' > ~opam/opam-repository/$pkg.commit" ; \
done
# OPAM dependencies
RUN git -C /home/opam/opam-repository pull
RUN opam update -y && opam upgrade -y
# install vanilla OCaml compiler
RUN opam switch create $OCAML_VERSION
# Remove .git files for submodules
RUN for pkg in async_kernel digestif graphql_ppx ocaml-extlib rpc_parallel ; do \
sudo rm -f $EXTERNAL_PKG_DIR/$pkg/.git ; \
done
# use vanilla OCaml compiler
RUN opam switch $OCAML_VERSION
RUN eval $(opam env)
# Install OPAM packages for vanilla compiler
ADD /src/opam.export .
RUN opam switch import opam.export ; rm opam.export
# Pin packages for vanilla compiler
RUN for pkg in ocaml-sodium rpc_parallel ocaml-extlib digestif async_kernel coda_base58 graphql_ppx ; do \
cd $EXTERNAL_PKG_DIR/$pkg && opam pin -y add . ; \
done
# Install nix
RUN mkdir --mode=700 /home/opam/.gnupg
RUN echo "disable-ipv6" >> /home/opam/.gnupg/dirmngr.conf
RUN sudo apt-get install gnupg2 && curl -o install-nix-2.3.2 https://releases.nixos.org/nix/nix-2.3.3/install && \
curl -o install-nix-2.3.2.asc https://releases.nixos.org/nix/nix-2.3.3/install.asc && \
gpg2 --import < $CODA_DIR/.nix-key.gpg.asc && \
gpg2 --recv-keys B541D55301270E0BCF15CA5D8170B4726D7198DE && \
gpg2 --verify ./install-nix-2.3.2.asc && \
sh ./install-nix-2.3.2 && \
USER=opam . ~/.nix-profile/etc/profile.d/nix.sh && \
nix-env --option sandbox false -iA cachix -f https://cachix.org/api/v1/install
# we used to delete the repo here
# we now leave it intact, in case updating OPAM in CI requires pinned package sources
# TEMP HACK (for libp2p_helper nixless builds)
RUN sudo apt-get install --yes wget
RUN cd /usr/lib && sudo wget https://dl.google.com/go/go1.13.10.linux-amd64.tar.gz && sudo tar -xvf go1.13.10.linux-amd64.tar.gz && sudo rm go1.13.10.linux-amd64.tar.gz
RUN echo 'export PATH="$PATH:/usr/lib/go/bin"' >> /home/opam/.bashrc
# The Ocaml images are set to London time for reason. UTC makes reading the logs
# easier.
RUN sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime
# Unlimit stack for future shells that might use spacetime
RUN echo ulimit -s unlimited >> ~/.bashrc