Skip to content

Commit

Permalink
RA-60: Cardano-submit-api added to dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mlinnik committed May 8, 2024
1 parent 24f527d commit 2c85165
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
8 changes: 4 additions & 4 deletions config/mainnet/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AlonzoGenesisFile": "/config/alonzo-genesis.json",
"AlonzoGenesisFile": "/current/alonzo-genesis.json",
"AlonzoGenesisHash": "0e44ea3a31d8e93c9c661b3a4d2ad57ff432e2c3e0341fb8954eb64f8f242613",
"ByronGenesisFile": "/config/byron-genesis.json",
"ByronGenesisFile": "/current/byron-genesis.json",
"ByronGenesisHash": "5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb",
"ConwayGenesisFile": "/config/conway-genesis.json",
"ConwayGenesisFile": "/current/conway-genesis.json",
"ConwayGenesisHash": "b84bce2d465bcdb38ebd873f126a866d7ebceb154357496396fb602104329299",
"EnableP2P": true,
"LastKnownBlockVersion-Alt": 0,
Expand All @@ -14,7 +14,7 @@
"PeerSharing": true,
"Protocol": "Cardano",
"RequiresNetworkMagic": "RequiresNoMagic",
"ShelleyGenesisFile": "/config/shelley-genesis.json",
"ShelleyGenesisFile": "/current/shelley-genesis.json",
"ShelleyGenesisHash": "40710bcc4e024224641dc12fe1e5e478d2c3d3aa7ad4f032283ddcc73b2ddb03",
"TargetNumberOfActivePeers": 20,
"TargetNumberOfEstablishedPeers": 50,
Expand Down
30 changes: 12 additions & 18 deletions docker/.env.dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
LOG=INFO
NETWORK=preprod
# mainnet, preprod, testnet, devkit
# mainnet, preprod, preview, sanchonet, devkit
PROTOCOL_MAGIC=1
# mainnet 764824073, preprod 1, testnet 2, devkit 42
# mainnet 764824073, preprod 1, preview 2, sanchonet 4, devkit 42
NETWORK_MAGIC=${PROTOCOL_MAGIC}

# Common env
# Postgres variables
DB_NAME=rosetta-java
DB_USER=rosetta_db_admin
DB_SECRET=weakpwd#123_d

# Postgres variables
DB_NAME=rosetta-java-preprod
DB_HOST=localhost
DB_PORT=5432
DB_SCHEMA=${NETWORK}
Expand All @@ -21,15 +19,12 @@ CARDANO_NODE_PORT=3001
CARDANO_NODE_VERSION=8.9.0
CARDANO_NODE_SUBMIT_HOST=cardano-submit-api
NODE_SUBMIT_API_PORT=8090
CARDANO_NODE_SOCKET=/ipc/node.socket

# Application env
CARDANO_NODE_SOCKET_PATH=./node-ipc
CARDANO_NODE_SOCKET=${CARDANO_NODE_SOCKET_PATH}/node.socket
# Api env
API_SPRING_PROFILES_ACTIVE=dev
# staging, h2, test. Additional profiles: mempool (if mempool should be activated)
API_PORT=8081
TRANSACTION_TTL=3000

DB_CONNECTION_PARAMS_PROVIDER_TYPE=ENVIRONMENT
DB_DRIVER_CLASS_NAME=org.postgresql.Driver

ROSETTA_VERSION=1.4.13
TOPOLOGY_FILEPATH=/current/topology.json
Expand All @@ -41,10 +36,9 @@ API_NODE_SOCKET_PATH=./node/node.socket

PRINT_EXCEPTION=true

## Yaci Indexer env
YACI_SPRING_PROFILES=postgres
# database profiles: h2, h2-testData, postgres
INDEXER_NODE_PORT=3001
MEMPOOL_ENABLED=true

# Devkit
HOST_N2C_SOCAT_PORT=3333
DEVKIT_ENABLED=true
MEMPOOL_ENABLED=false
# Haven't implemented yet
28 changes: 20 additions & 8 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
FROM ubuntu:22.04 AS cardano-builder

ARG CABAL_VERSION=3.8.1.0
ARG GHC_VERSION=8.10.7
ARG CARDANO_NODE_VERSION=8.9.2

WORKDIR /root/src

# Install dependencies
Expand All @@ -22,13 +18,20 @@ RUN bash -c "curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org
ENV PATH=/root/.local/bin:/root/.ghcup/bin:/root/.cabal/bin:${PATH}

# Install cabal
ARG CABAL_VERSION=3.8.1.0

RUN bash -c "ghcup install cabal ${CABAL_VERSION}"
RUN bash -c "ghcup set cabal ${CABAL_VERSION}"

# Install GHC
ARG GHC_VERSION=8.10.7

RUN bash -c "ghcup install ghc ${GHC_VERSION}"
RUN bash -c "ghcup set ghc ${GHC_VERSION}"

# Cardano node version
ARG CARDANO_NODE_VERSION=8.9.2

# Install sodium
RUN export IOHKNIX_VERSION=$(curl https://raw.githubusercontent.com/IntersectMBO/cardano-node/$CARDANO_NODE_VERSION/flake.lock | jq -r '.nodes.iohkNix.locked.rev') \
&& echo "iohk-nix version: $IOHKNIX_VERSION" \
Expand Down Expand Up @@ -109,16 +112,21 @@ WORKDIR /root/src/cardano-node
RUN bash -c "cabal update"
RUN bash -c "cabal build all"
RUN bash -c "cabal build cardano-cli"
RUN bash -c "cabal build cardano-submit-api"

RUN mkdir -p /root/.local/bin \
&& cp -p "$(./scripts/bin-path.sh cardano-node)" /root/.local/bin/ \
&& cp -p "$(./scripts/bin-path.sh cardano-cli)" /root/.local/bin/
&& cp -p "$(./scripts/bin-path.sh cardano-cli)" /root/.local/bin/ \
&& cp -p "$(./scripts/bin-path.sh cardano-submit-api)" /root/.local/bin/

# Compile java applications
FROM maven:3.9.6-sapmachine-21 AS java-builder
FROM ubuntu:22.04 AS java-builder

WORKDIR /root/app

RUN apt-get update --fix-missing \
&& apt install -y --no-install-recommends openjdk-21-jdk maven

COPY ./pom.xml /root/app/pom.xml

COPY ./api /root/app/api
Expand All @@ -128,12 +136,12 @@ COPY ./test-data-generator /root/app/test-data-generator
RUN --mount=type=cache,target=/root/.m2 mvn clean package -DskipTests

# Main
FROM eclipse-temurin:21-jdk
FROM ubuntu:22.04

WORKDIR /

# Install postgres
ARG PG_VERSION=11
ARG PG_VERSION=14

RUN apt-get update --fix-missing \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y wget sudo gnupg \
Expand All @@ -147,9 +155,13 @@ RUN apt-get update --fix-missing \
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/$PG_VERSION/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/$PG_VERSION/main/postgresql.conf

# Install jdk 21
RUN apt -y --no-install-recommends install openjdk-21-jdk

# Copy cardano node
COPY --from=cardano-builder /usr/local/lib /usr/local/lib
COPY --from=cardano-builder /root/.local/bin/cardano-* /usr/local/bin/
COPY --from=cardano-builder /root/src/cardano-node/cardano-submit-api/config/tx-submit-mainnet-config.yaml /root/cardano-submit-api

ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
ENV PATH=/usr/local/lib/:$PATH
Expand Down
7 changes: 5 additions & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/bash
echo "entrypoint - run node"
cp -r /config/${NETWORK}/* /config/
cardano-node run --database-path /data/db --host-addr 0.0.0.0 --port ${CARDANO_NODE_PORT} --socket-path /ipc/node.socket --topology /config/topology.json --config /config/config.json > /logs/node.log &
cp -r /config/${NETWORK}/* /current/
cardano-node run --database-path /data/db --host-addr 0.0.0.0 --port ${CARDANO_NODE_PORT} --socket-path ${CARDANO_NODE_SOCKET} --topology /current/topology.json --config /current/config.json > /logs/node.log &

echo "entrypoint - run submit api"
cardano-submit-api --config /root/cardano-submit-api/tx-submit-mainnet-config.yaml --socket-path ${CARDANO_NODE_SOCKET} --port ${NODE_SUBMIT_API_PORT} --testnet-magic ${PROTOCOL_MAGIC} > /logs/submit-api.log &

echo "entrypoint - run postgres"
/etc/init.d/postgresql start
Expand Down

0 comments on commit 2c85165

Please sign in to comment.