Skip to content

refactor: streamlining docker compose configuration. #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .env.IntegrationTest
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ NETWORK=devkit
PROTOCOL_MAGIC=42

## Postgres image
DB_IMAGE_NAME=postgres
DB_IMAGE_TAG=latest
PG_VERSION_TAG=REL_14_11

## Yaci image
YACI_VERSION=0.10.5
Expand Down Expand Up @@ -41,6 +40,8 @@ SNAPSHOT_DIGEST=latest
AGGREGATOR_ENDPOINT=
# if not set standard values will be used
GENESIS_VERIFICATION_KEY=
ANCILLARY_VERIFICATION_KEY=


## Api env
API_DOCKER_IMAGE_TAG=main
Expand Down Expand Up @@ -138,4 +139,4 @@ DB_POSTGRES_MAX_PARALLEL_WORKERS=4
DB_POSTGRES_SEQ_PAGE_COST=1.0
DB_POSTGRES_JIT=off
DB_POSTGRES_BGWRITER_LRU_MAXPAGES=50
DB_POSTGRES_BGWRITER_DELAY=500ms
DB_POSTGRES_BGWRITER_DELAY=500ms
19 changes: 10 additions & 9 deletions .env.docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
API_SPRING_PROFILES_ACTIVE=online
LOG=INFO
NETWORK=mainnet
# mainnet, preprod, preview, sanchonet, devkit
# mainnet, preprod, preview, devkit
PROTOCOL_MAGIC=764824073
# mainnet 764824073, preprod 1, preview 2, sanchonet 4, devkit 42
# mainnet 764824073, preprod 1, preview 2, devkit 42

## Postgres image
DB_IMAGE_NAME=postgres
DB_IMAGE_TAG=14.11-bullseye
PG_VERSION_TAG=REL_14_11

## Postgres variables
DB_NAME=rosetta-java
Expand All @@ -18,28 +17,29 @@ DB_HOST=db
# Service name in docker-compose or local db
DB_PORT=5432
DB_SCHEMA=${NETWORK}
DB_PATH=data

DB_PATH=/opt/rosetta-java-${NETWORK}/sql_data
## Cardano Node variables
CARDANO_NODE_HOST=cardano-node
# Service name in docker-compose or local cardano node
CARDANO_NODE_PORT=3001
# Uncomment if you are using local cardano node
CARDANO_NODE_VERSION=10.2.1
CARDANO_NODE_SUBMIT_HOST=cardano-submit-api
CARDANO_NODE_VERSION=10.3.1
CARDANO_NODE_SUBMIT_HOST=$CARDANO_NODE_HOST
NODE_SUBMIT_API_PORT=8090
CARDANO_NODE_DIR=/node
CARDANO_NODE_DIR=/opt/rosetta-java-${NETWORK}/node_data
CARDANO_NODE_SOCKET_PATH=${CARDANO_NODE_DIR}/node.socket
CARDANO_NODE_DB=${CARDANO_NODE_DIR}/db
CARDANO_CONFIG=./config/${NETWORK}

## Mithril
MITHRIL_SYNC=true
MITHRIL_VERSION=2517.1
SNAPSHOT_DIGEST=latest
# if not set standard values will be used
AGGREGATOR_ENDPOINT=
# if not set standard values will be used
GENESIS_VERIFICATION_KEY=
ANCILLARY_VERIFICATION_KEY=

## Api env
API_DOCKER_IMAGE_TAG=main
Expand All @@ -49,6 +49,7 @@ PRINT_EXCEPTION=true

ROSETTA_VERSION=1.4.13
TOPOLOGY_FILEPATH=/config/topology.json

GENESIS_SHELLEY_PATH=/config/shelley-genesis.json
GENESIS_BYRON_PATH=/config/byron-genesis.json
GENESIS_ALONZO_PATH=/config/alonzo-genesis.json
Expand Down
96 changes: 96 additions & 0 deletions .env.docker-compose-preprod
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
## Main variables
API_SPRING_PROFILES_ACTIVE=online
LOG=INFO
NETWORK=preprod
# mainnet, preprod, preview, devkit
PROTOCOL_MAGIC=1
# mainnet 764824073, preprod 1, preview 2, devkit 42

## Postgres image
PG_VERSION_TAG=REL_14_11

## Postgres variables
DB_NAME=rosetta-java
DB_USER=rosetta_db_admin
DB_SECRET=weakpwd#123_d
DB_HOST=db
# Service name in docker-compose or local db
DB_PORT=5432
DB_SCHEMA=${NETWORK}
DB_PATH=/opt/rosetta-java-${NETWORK}/sql_data

## Cardano Node variables
CARDANO_NODE_HOST=cardano-node
# Service name in docker-compose or local cardano node
CARDANO_NODE_PORT=3001
# Uncomment if you are using local cardano node
CARDANO_NODE_VERSION=10.3.1
CARDANO_NODE_SUBMIT_HOST=$CARDANO_NODE_HOST
NODE_SUBMIT_API_PORT=8090
CARDANO_NODE_DIR=/opt/rosetta-java-${NETWORK}/node_data
CARDANO_NODE_SOCKET_PATH=${CARDANO_NODE_DIR}/node.socket
CARDANO_NODE_DB=${CARDANO_NODE_DIR}/db
CARDANO_CONFIG=./config/${NETWORK}

## Mithril
MITHRIL_SYNC=true
MITHRIL_VERSION=2517.1
SNAPSHOT_DIGEST=latest
# if not set standard values will be used
AGGREGATOR_ENDPOINT=
# if not set standard values will be used
GENESIS_VERIFICATION_KEY=
ANCILLARY_VERIFICATION_KEY=

## Api env
API_DOCKER_IMAGE_TAG=main
# staging, h2, test. Additional profiles: mempool (if mempool should be activated)
API_PORT=8082
PRINT_EXCEPTION=true

ROSETTA_VERSION=1.4.13
TOPOLOGY_FILEPATH=/config/topology.json

GENESIS_SHELLEY_PATH=/config/shelley-genesis.json
GENESIS_BYRON_PATH=/config/byron-genesis.json
GENESIS_ALONZO_PATH=/config/alonzo-genesis.json
GENESIS_CONWAY_PATH=/config/conway-genesis.json
SEARCH_PAGE_SIZE=100

## Yaci Indexer env
INDEXER_DOCKER_IMAGE_TAG=main
PRUNING_ENABLED=false
#The number of safe blocks to keep in the store. 2160 blocks *(20 seconds/block in average)=4320 seconds=12 hours.
PRUNING_SAFE_BLOCKS=2160
#Run transaction pruning every 600 seconds or 10 minutes.
PRUNING_INTERVAL=600

YACI_SPRING_PROFILES=postgres,n2c-socket
# database profiles: h2, h2-testdata, postgres
MEMPOOL_ENABLED=false

## Devkit env
DEVKIT_ENABLED=false
DEVKIT_URL=yaci-cli
DEVKIT_PORT=3333

## Logger Config
LOG_FILE_PATH=/var/log/rosetta-java
LOG_FILE_NAME=/var/log/rosetta-java/rosetta-java.log
LOG_FILE_MAX_SIZE=10MB
LOG_FILE_MAX_HISTORY=10

YACI_HTTP_BASE_URL=http://yaci-indexer:9095/api/v1
YACI_INDEXER_PORT=9095
HTTP_CONNECT_TIMEOUT_SECONDS=5
HTTP_REQUEST_TIMEOUT_SECONDS=5

## DB tuning / debugging
API_DB_SHOW_SQL=false
API_DB_MONITOR_PERFORMANCE=false #only needed for debugging and diagnostics

## Basic db pool tuning, generally should not be changed but can be changed rarely if needed
API_DB_POOL_MAX_LIFETIME_MS=2000000
API_DB_POOL_CONNECTION_TIMEOUT_MS=100000
API_DB_KEEP_ALIVE_MS=60000
API_DB_LEAK_CONNECTIONS_WARNING_MS=60000
6 changes: 3 additions & 3 deletions .env.h2
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Main variables
LOG=INFO
NETWORK=devkit
# mainnet, preprod, preview, sanchonet, devkit
# mainnet, preprod, preview, devkit
PROTOCOL_MAGIC=42
# mainnet 764824073, preprod 1, preview 2, sanchonet 4, devkit 42
# mainnet 764824073, preprod 1, preview 2, devkit 42

## H2 image
DB_IMAGE_NAME=h2
Expand All @@ -19,7 +19,7 @@ CARDANO_NODE_HOST=localhost
# Service name in docker-compose or local cardano node
CARDANO_NODE_PORT=3001
# Uncomment if you are using local cardano node
CARDANO_NODE_VERSION=10.2.1
CARDANO_NODE_VERSION=10.3.1
CARDANO_NODE_SUBMIT_HOST=localhost
NODE_SUBMIT_API_PORT=8090

Expand Down
6 changes: 3 additions & 3 deletions .env.h2-testdata
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Main variables
LOG=INFO
NETWORK=devkit
# mainnet, preprod, preview, sanchonet, devkit
# mainnet, preprod, preview, devkit
PROTOCOL_MAGIC=42
# mainnet 764824073, preprod 1, preview 2, sanchonet 4, devkit 42
# mainnet 764824073, preprod 1, preview 2, devkit 42

## H2 image
DB_IMAGE_NAME=h2
Expand All @@ -19,7 +19,7 @@ CARDANO_NODE_HOST=localhost
# Service name in docker-compose or local cardano node
CARDANO_NODE_PORT=3001
# Uncomment if you are using local cardano node
CARDANO_NODE_VERSION=10.2.1
CARDANO_NODE_VERSION=10.3.1
CARDANO_NODE_SUBMIT_HOST=localhost
NODE_SUBMIT_API_PORT=8090

Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/feature-mvn-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 21
uses: actions/setup-java@v3
# - name: Set up JDK 21
# uses: actions/setup-java@v3
# with:
# java-version: '21'
# distribution: 'temurin'
# cache: maven

- name: Set up Amazon Corretto
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
distribution: 'corretto'
java-version: 24
cache: maven

- name: Build project
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/sonar-cloud-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 21
uses: actions/setup-java@v3
# - name: Set up JDK 21
# uses: actions/setup-java@v3
# with:
# java-version: '21'
# distribution: 'temurin'
# cache: maven

- name: Set up Amazon Corretto
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
distribution: 'corretto'
java-version: 24
cache: maven

- name: Build
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ settings.xml
!.env.h2
!.env.h2-testdata
!.env.docker-compose
!.env.docker-compose-preprod
!.env.docker-compose-profile-entry-level
!.env.docker-compose-profile-mid-level

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[![License](https://img.shields.io:/github/license/cardano-foundation/cardano-rosetta-java?label=license)](https://github.com/cardano-foundation/cardano-rosetta-java/blob/master/LICENSE)
![Discord](https://img.shields.io/discord/1022471509173882950)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=cardano-foundation_cardano-rosetta-java&metric=coverage)](https://sonarcloud.io/summary/overall?id=cardano-foundation_cardano-rosetta-java)
[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B45571%2Fgithub.com%2Fcardano-foundation%2Fcardano-rosetta-java.svg?type=shield&issueType=license)](https://app.fossa.com/projects/custom%2B45571%2Fgithub.com%2Fcardano-foundation%2Fcardano-rosetta-java?ref=badge_shield&issueType=license)

## What the project is about?

Expand Down Expand Up @@ -100,15 +99,15 @@ For every Release we provide pre-built docker images stored in the DockerHub Rep
To start it use the following command:

```bash
docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile --env-file ./docker/.env.docker-profile-mid-level -p 8082:8082 --shm-size=4g -d cardanofoundation/cardano-rosetta-java:1.2.7
docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile --env-file ./docker/.env.docker-profile-mid-level -p 8082:8082 --shm-size=4g -d cardanofoundation/cardano-rosetta-java:1.2.8
```

Changes to the configuration can be made by adjusting the `docker/.env.dockerfile` file. For more information on the environment variables, please refer to the [documentation](https://cardano-foundation.github.io/cardano-rosetta-java/docs/install-and-deploy/env-vars).

If you want to use the `cardano-submit-api` you can additionally expose port `8090`. It can then be used to submit raw cbor transaction (API documentation here: [Link](https://input-output-hk.github.io/cardano-rest/submit-api/))

```bash
docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile --env-file ./docker/.env.docker-profile-mid-level -p 8090:8090 -p 8082:8082 --shm-size=4g -d cardanofoundation/cardano-rosetta-java:1.2.7
docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile --env-file ./docker/.env.docker-profile-mid-level -p 8090:8090 -p 8082:8082 --shm-size=4g -d cardanofoundation/cardano-rosetta-java:1.2.8
```

### Docker compose
Expand Down
20 changes: 16 additions & 4 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
FROM ubuntu:22.04 AS build-common
FROM ubuntu:24.04 AS build-common
WORKDIR /build

# Install necessary tools but not OpenJDK from apt
RUN apt update --fix-missing \
&& apt install -y --no-install-recommends openjdk-21-jdk maven curl \
&& apt install -y --no-install-recommends maven curl ca-certificates \
&& apt clean

# Download and setup JDK 24.0.1
RUN mkdir -p /opt/java \
&& curl -L https://download.java.net/java/GA/jdk24.0.1/24a58e0e276943138bf3e963e6291ac2/9/GPL/openjdk-24.0.1_linux-x64_bin.tar.gz -o /opt/jdk.tar.gz \
&& tar -xzf /opt/jdk.tar.gz -C /opt/java \
&& rm /opt/jdk.tar.gz

# Set JAVA_HOME and update PATH
ENV JAVA_HOME=/opt/java/jdk-24.0.1
ENV PATH="${JAVA_HOME}/bin:${PATH}"

COPY ./pom.xml /build/pom.xml
COPY ./api /build/api
COPY ./yaci-indexer /build/yaci-indexer
COPY ./test-data-generator /build/test-data-generator
COPY ./.git .git

RUN --mount=type=cache,target=/root/.m2 mvn clean package -DskipTests
RUN --mount=type=cache,target=/root/.m2 mvn -U clean package -DskipTests
RUN java --version

WORKDIR /app
RUN cp /build/api/target/*.jar /app/api.jar
RUN rm -rf /build

ENTRYPOINT ["java", "--enable-preview", "-jar", "/app/api.jar"]

CMD ["/bin/sh", "-c", "bash"]
CMD ["/bin/sh", "-c", "bash"]
Loading