|
| 1 | +# Copyright 2020 Coinbase, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# Compile golang |
| 16 | +FROM ubuntu:18.04 as golang-builder |
| 17 | + |
| 18 | +RUN mkdir -p /app \ |
| 19 | + && chown -R nobody:nogroup /app |
| 20 | +WORKDIR /app |
| 21 | + |
| 22 | +RUN apt-get update && apt-get install -y curl make gcc g++ git |
| 23 | +ENV GOLANG_VERSION 1.15.2 |
| 24 | +ENV GOLANG_DOWNLOAD_SHA256 b49fda1ca29a1946d6bb2a5a6982cf07ccd2aba849289508ee0f9918f6bb4552 |
| 25 | +ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz |
| 26 | + |
| 27 | +RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ |
| 28 | + && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ |
| 29 | + && tar -C /usr/local -xzf golang.tar.gz \ |
| 30 | + && rm golang.tar.gz |
| 31 | + |
| 32 | +ENV GOPATH /go |
| 33 | +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH |
| 34 | +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" |
| 35 | + |
| 36 | +# Compile geth |
| 37 | +FROM golang-builder as geth-builder |
| 38 | + |
| 39 | +# VERSION: go-ethereum v.1.9.23 |
| 40 | +RUN git clone https://github.com/ethereum/go-ethereum \ |
| 41 | + && cd go-ethereum \ |
| 42 | + && git checkout 8c2f271528f9cccf541c6ea1c022e98407f26872 |
| 43 | + |
| 44 | +RUN cd go-ethereum \ |
| 45 | + && make geth |
| 46 | + |
| 47 | +RUN mv go-ethereum/build/bin/geth /app/geth \ |
| 48 | + && rm -rf go-ethereum |
| 49 | + |
| 50 | +# Compile rosetta-ethereum |
| 51 | +FROM golang-builder as rosetta-builder |
| 52 | + |
| 53 | +# Use native remote build context to build in any directory |
| 54 | +COPY . src |
| 55 | +RUN cd src \ |
| 56 | + && go build |
| 57 | + |
| 58 | +RUN mv src/rosetta-ethereum /app/rosetta-ethereum \ |
| 59 | + && mkdir /app/ethereum \ |
| 60 | + && mv src/ethereum/call_tracer.js /app/ethereum/call_tracer.js \ |
| 61 | + && mv src/ethereum/geth.toml /app/ethereum/geth.toml \ |
| 62 | + && rm -rf src |
| 63 | + |
| 64 | +## Build Final Image |
| 65 | +FROM ubuntu:18.04 |
| 66 | + |
| 67 | +RUN mkdir -p /app \ |
| 68 | + && chown -R nobody:nogroup /app \ |
| 69 | + && mkdir -p /data \ |
| 70 | + && chown -R nobody:nogroup /data |
| 71 | + |
| 72 | +WORKDIR /app |
| 73 | + |
| 74 | +# Copy binary from geth-builder |
| 75 | +COPY --from=geth-builder /app/geth /app/geth |
| 76 | + |
| 77 | +# Copy binary from rosetta-builder |
| 78 | +COPY --from=rosetta-builder /app/ethereum /app/ethereum |
| 79 | +COPY --from=rosetta-builder /app/rosetta-ethereum /app/rosetta-ethereum |
| 80 | + |
| 81 | +# Set permissions for everything added to /app |
| 82 | +RUN chmod -R 755 /app/* |
| 83 | + |
| 84 | +CMD ["/app/rosetta-ethereum", "run"] |
0 commit comments