Skip to content

Commit

Permalink
New rosetta docker
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Oct 6, 2023
1 parent 8a3c9cd commit eab5933
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 170 deletions.
3 changes: 2 additions & 1 deletion buildkite/scripts/build-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo "--- Build libp2p_helper TODO: use the previously uploaded build artifact"
make -C src/app/libp2p_helper

MAINNET_TARGETS=""
[[ ${MINA_BUILD_MAINNET} ]] && MAINNET_TARGETS="src/app/cli/src/mina_mainnet_signatures.exe src/app/rosetta/rosetta_mainnet_signatures.exe "
[[ ${MINA_BUILD_MAINNET} ]] && MAINNET_TARGETS="src/app/cli/src/mina_mainnet_signatures.exe src/app/rosetta/rosetta_mainnet_signatures.exe src/app/rosetta/ocaml-signer/signer_mainnet_signatures.exe"

echo "--- Build all major tagets required for packaging"
echo "Building from Commit SHA: ${MINA_COMMIT_SHA1}"
Expand All @@ -33,6 +33,7 @@ dune build "--profile=${DUNE_PROFILE}" \
src/app/swap_bad_balances/swap_bad_balances.exe \
src/app/zkapp_test_transaction/zkapp_test_transaction.exe \
src/app/rosetta/rosetta_testnet_signatures.exe \
src/app/rosetta/ocaml-signer/signer_testnet_signatures.exe \
src/app/test_executive/test_executive.exe # 2>&1 | tee /tmp/buildocaml.log

echo "--- Bundle all packages for Debian ${MINA_DEB_CODENAME}"
Expand Down
85 changes: 49 additions & 36 deletions dockerfiles/stages/4-production → dockerfiles/Dockerfile-mina-rosetta
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
ARG image=ubuntu:focal
FROM ${image} AS production
ARG deb_codename=focal
ARG deb_version
ARG deb_release=unstable
ARG network=mainnet


ARG psql_version=13

Expand All @@ -18,6 +22,23 @@ 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.
# Stretch-only Deps:
# libffi6
# libprocps6
# libjemalloc1
# Buster-only Deps:
# libffi7
# libprocps7
# libjemalloc2
# Bullseye/Focal-only Deps:
# libffi7
# libprocps8
# libjemalloc2


# --- Dependencies across many platforms
RUN apt-get update --quiet --yes \
&& apt-get upgrade --quiet --yes \
Expand Down Expand Up @@ -46,33 +67,6 @@ RUN curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
postgresql-"$psql_version" \
postgresql-client-"$psql_version"

# --- Debian 11 "Bullseye" Dependencies
RUN test "$deb_codename" = "bullseye" \
&& apt-get update -y \
&& apt-get install -y \
libjemalloc2 \
libprocps8 \
libffi7 \
|| exit 0

# --- Debian 10 "Buster" Dependencies
RUN test "$deb_codename" = "buster" \
&& apt-get update --quiet --yes \
&& apt-get install --quiet --yes --no-install-recommends \
libjemalloc2 \
libprocps7 \
libffi6 \
|| exit 0

# --- Ubuntu 20.04 "Focal Fossa" Dependencies
RUN test "$deb_codename" = "focal" \
&& apt-get update --quiet --yes \
&& apt-get install --quiet --yes --no-install-recommends \
libjemalloc2 \
libprocps8 \
libffi7 \
|| exit 0

# --- Install rosetta-cli

# The following commands install rosetta-cli with an updated rosetta-sdk-go dependency, which supports delegation transactions.
Expand All @@ -89,6 +83,16 @@ RUN export GOBIN="$(pwd)/bin" \
&& /usr/lib/go/bin/go mod tidy \
&& /usr/lib/go/bin/go install


# Rosetta-demo artifacts / build dir removal:
# Make rosetta-crucial components and the generate_keypair tool
# && dune build --profile=${DUNE_PROFILE} \
# && _build/default/src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe \
# --config-file src/app/rosetta/demo-config.json \
# --genesis-dir ${HOME}/demo-genesis \
# && mv _build/default/src/app $HOME/app \
# && rm -rf _build

# --- Generate en_US.UTF-8 locale to allow use of O(1) Labs DB dumps
RUN locale-gen en_US.UTF-8

Expand All @@ -99,15 +103,24 @@ RUN mkdir -p --mode=700 ${MINA_CONFIG_DIR}/wallets/store/ \
> ${MINA_CONFIG_DIR}/wallets/store/${PK} \
&& chmod go-rwx ${MINA_CONFIG_DIR}/wallets/store/${PK}

# --- Copy artifacts from the 3-builder stage
COPY --from=builder /home/opam/app/* /usr/local/bin/
COPY --from=builder /home/opam/mina/src/app/rosetta/*.sh /rosetta/
COPY --from=builder /home/opam/mina/src/app/rosetta/*.conf /rosetta/
COPY --from=builder /home/opam/mina/src/app/rosetta/README.md /rosetta/
COPY --from=builder /home/opam/mina/src/app/rosetta/rosetta-cli-config/*.json /rosetta/rosetta-cli-config/
COPY --from=builder /home/opam/mina/src/app/rosetta/rosetta-cli-config/*.ros /rosetta/rosetta-cli-config/
COPY --from=builder /home/opam/mina/src/app/archive/*.sql /archive/
COPY --from=builder /home/opam/mina/genesis_ledgers /genesis_ledgers/

# 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] http://packages.o1test.net $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" \
&& rm -rf /var/lib/apt/lists/*


# --- Copy artifacts
COPY src/app/rosetta/*.sh /rosetta/
COPY src/app/rosetta/*.conf /rosetta/
COPY src/app/rosetta/README.md /rosetta/
COPY src/app/rosetta/rosetta-cli-config/*.json /rosetta/rosetta-cli-config/
COPY src/app/rosetta/rosetta-cli-config/*.ros /rosetta/rosetta-cli-config/
COPY src/app/archive/*.sql /archive/
COPY genesis_ledgers /genesis_ledgers/

# --- Set up postgres
USER postgres
Expand Down
72 changes: 0 additions & 72 deletions dockerfiles/stages/3-builder

This file was deleted.

58 changes: 0 additions & 58 deletions dockerfiles/stages/4-deb-builder

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/rebuild-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ copy_common_daemon_configs() {
# Copy signature-based Binaries (based on signature type $2 passed into the function)
cp ./default/src/app/cli/src/mina_${2}_signatures.exe "${BUILDDIR}/usr/local/bin/mina"
cp ./default/src/app/rosetta/rosetta_${2}_signatures.exe "${BUILDDIR}/usr/local/bin/mina-rosetta"

cp ./default/src/app/rosetta/ocaml-signer/signer_${2}_signatures.exe "${BUILDDIR}/usr/local/bin/mina-rosetta-ocaml-signer"

# Copy over Build Configs (based on $2)
mkdir -p "${BUILDDIR}/etc/coda/build_config"
# Use parameter expansion to either return "mainnet.mlh" or "devnet.mlh"
Expand Down
2 changes: 1 addition & 1 deletion scripts/release-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mina-batch-txn)
VERSION="${VERSION}-${NETWORK##*=}"
;;
mina-rosetta)
DOCKERFILE_PATH="dockerfiles/stages/1-build-deps dockerfiles/stages/2-opam-deps dockerfiles/stages/3-builder dockerfiles/stages/4-production"
DOCKERFILE_PATH="dockerfiles/Dockerfile-mina-rosetta"
;;
mina-zkapp-test-transaction)
DOCKERFILE_PATH="dockerfiles/Dockerfile-zkapp-test-transaction"
Expand Down
2 changes: 1 addition & 1 deletion src/app/rosetta/rosetta_testnet_signatures.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ open Async

let () =
Command.run
(Command.async ~summary:"Run Rosetta process on top of Coda" command)
(Command.async ~summary:"Run Rosetta process on top of Mina" command)

0 comments on commit eab5933

Please sign in to comment.