-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
77 lines (62 loc) · 2.16 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
# USAGE INSTRUCTIONS:
#
# Docker Container Label: gcr.io/celo-testnet/rosetta
#
# Local Build For testing:
# docker build -t gcr.io/celo-testnet/rosetta:$USER .
#
# Run rosetta
# docker rm rosetta # Removes rosetta named container
# docker run --name rosetta gcr.io/celo-testnet/rosetta:$USER
# # or to create & delete
# docker run -rm gcr.io/celo-testnet/rosetta:$USER
#
# Build & Deploy:
# export COMMIT_SHA=$(git rev-parse HEAD)
# docker build --build-arg COMMIT_SHA=$COMMIT_SHA -t gcr.io/celo-testnet/rosetta:$COMMIT_SHA .
# docker push gcr.io/celo-testnet/rosetta:$COMMIT_SHA
#---------------------------------------------------------------------
# Stage 1: Build Rosetta
# Outputs: binary @ /rosetta/rosetta
#---------------------------------------------------------------------
FROM golang:1.19-bookworm as builder
WORKDIR /rosetta
RUN headers_package="linux-headers-$(dpkg --print-architecture)" && \
apt update && \
apt install -y build-essential git musl-dev $headers_package
# Downnload dependencies & cache them in docker layer
COPY go.mod .
COPY go.sum .
RUN go mod download
# Build project
# (this saves to redownload everything when go.mod/sum didn't change)
COPY . .
RUN go build --tags musl -o rosetta .
#---------------------------------------------------------------------
# Stage 2: Build Final container
# Integrates celo-blockchain & rosetta builds into a single container
# Outputs: rosetta & geth binaries on /usr/loca/bin
#---------------------------------------------------------------------
# geth mainnet
FROM us.gcr.io/celo-org/geth:1.8.4
ARG COMMIT_SHA
RUN apt update &&\
apt install -y ca-certificates wget &&\
rm -rf /var/cache/apt &&\
rm -rf /var/lib/apt/lists/* &&\
ln -sf /bin/bash /bin/sh
COPY --from=builder /rosetta/rosetta /usr/local/bin/
RUN echo $COMMIT_SHA > /version.txt
RUN mkdir /data
RUN mkdir /logs
RUN mkdir -p /var
EXPOSE 8080/tcp
EXPOSE 30503/tcp
EXPOSE 30503/udp
ENV ROSETTA_DATADIR="/data"
ENV ROSETTA_RPC_PORT="8080"
ENV ROSETTA_GETH_LOGFILE="/logs/celo.log"
ENV ROSETTA_GETH_IPCPATH="/var/geth.ipc"
ENV ROSETTA_GETH_BINARY="/usr/local/bin/geth"
ENTRYPOINT ["/usr/local/bin/rosetta"]
CMD ["run"]