-
Notifications
You must be signed in to change notification settings - Fork 206
/
Dockerfile.mimalloc
57 lines (47 loc) · 1.75 KB
/
Dockerfile.mimalloc
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
# How to test changes to this file
# docker build -f Dockerfile -t gcr.io/celo-testnet/geth:$USER .
# To locally run that image
# docker rm geth_container ; docker run --name geth_container gcr.io/celo-testnet/geth:$USER
# and connect to it with
# docker exec -t -i geth_container /bin/sh
#
# Once you are satisfied, build the image using
# export COMMIT_SHA=$(git rev-parse HEAD)
# docker build -f Dockerfile --build-arg COMMIT_SHA=$COMMIT_SHA -t gcr.io/celo-testnet/geth:$COMMIT_SHA .
#
# push the image to the cloud
# docker push gcr.io/celo-testnet/geth:$COMMIT_SHA
#
# To use this image for testing, modify GETH_NODE_DOCKER_IMAGE_TAG in celo-monorepo/.env file
# Build Geth in a stock Go builder container
FROM golang:1.16-alpine as builder
RUN apk add --no-cache make gcc musl-dev linux-headers git build-base cmake
RUN cd / && \
git clone -b v2.0.3 --depth 1 https://github.com/microsoft/mimalloc && \
cd mimalloc && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) && \
make install
ADD . /go-ethereum
RUN cd /go-ethereum && make geth-musl
# Pull Geth into a second stage deploy alpine container
FROM alpine:latest
ARG COMMIT_SHA
# Copy over compiled libmimalloc
COPY --from=builder /mimalloc/build/*.so.* /lib
RUN ln -s /lib/libmimalloc.so.* /lib/libmimalloc.so
ENV LD_PRELOAD=/lib/libmimalloc.so
ENV MIMALLOC_LARGE_OS_PAGES=1
RUN apk add --no-cache ca-certificates
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
RUN echo $COMMIT_SHA > /version.txt
ADD scripts/run_geth_in_docker.sh /
EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["sh", "/run_geth_in_docker.sh"]
# Add some metadata labels to help programatic image consumption
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""
LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"