-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
84 lines (76 loc) · 3 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
# Building this Image will include the running of all benchmarks in a "cold
# cache" state, and thus will take quite a bit of time (roughly 30-60 minutes,
# with Ganache excluded). The cache will be retained in the built Image, such
# that running the Image will execute benchmarks with a "warm cache". For
# example:
#
# docker build -t sim .
# docker run -t sim benchmark-hardhat
#
# To benchmark with a cleared cache, and without having to rebuild the entire
# tool environment, use something like:
#
# docker run --entrypoint /bin/bash -t sim -c "rm -rf cache && make benchmark-hardhat"
#
# You can also copy the cache from the built container to your docker host, so
# that it will be incorporated into a subsequent build of the Image, allowing a
# "warm cache" run in a freshly built Image. To do this, use something like:
#
# id=$(docker create sim)
# docker cp $id:/home/user/convex-shutdown-simulation/cache .
# docker rm -v $id
# # source: https://stackoverflow.com/a/31316636/406289
# docker build -t sim .
#
# BEWARE: This Image should not be published because it will contain your .env
# file, which contains your RPC url, which likely contains your private API key
# secret. (See https://stackoverflow.com/a/40762010/406289 .) Future work can
# take advantage of Docker's support for secrets, but unless/until there's a
# need to publish this Image, that would be overkill.
#
# Note: Lines in this file starting with "# " are assumed to be example usage
# commands and are verified by ./testDockerfile.sh
FROM debian
RUN apt-get update && \
apt-get install --yes curl git make xz-utils yarnpkg && \
ln -s /usr/bin/yarnpkg /usr/bin/yarn
# nix/dapptools don't like to install/run as root
RUN groupadd user && \
useradd -g user user && \
mkdir -p -m 0755 /home/user && \
chown user /home/user && \
mkdir -m 0755 /nix && \
chown user /nix
WORKDIR /home/user
USER user
# nix/dapptools install scripts require this environment:
ENV USER=user
ENV BASH_ENV=/home/user/.profile
ENV SHELL=/bin/bash
SHELL ["/bin/bash", "-c"]
WORKDIR convex-shutdown-simulation
USER root
RUN chown -R user:user /home/user
USER user
COPY --chown=user:user package.json .
COPY --chown=user:user yarn.lock .
RUN ln -s ~/.bashrc ~/.profile
RUN yarn && \
curl -L https://raw.githubusercontent.com/gakonst/foundry/master/foundryup/install | bash
# Don't combine these sequential RUN commands because we need fresh shell
# instances in order for each install script to take effect.
RUN foundryup && \
curl -L https://nixos.org/nix/install | bash
RUN curl -L https://dapp.tools/install | bash
COPY --chown=user:user .git .git
RUN dapp update
COPY --chown=user:user . .
# The following lines can be reordered to optimize Image rebuild times. RUN
# stable ones first, and leave unstable ones for last, so that your rebuild can
# hit the Layer cache for the stable ones.
RUN make benchmark-foundry
RUN make benchmark-hardhat
RUN make benchmark-dapptools
RUN make benchmark-ganache
RUN make benchmark-tenderly
ENTRYPOINT ["make"]