Skip to content

Commit

Permalink
Merge branch 'feat/RA-60-Single-docker-container' into feat/RA-87-Fix…
Browse files Browse the repository at this point in the history
…-docker-compose-build

# Conflicts:
#	.github/workflows/docker-build.yaml
  • Loading branch information
mlinnik committed May 8, 2024
2 parents d9923ea + 1bbf73e commit 9c81095
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- feat/RA-60-Single-docker-container
jobs:
docker-build-single-containe:
docker-build-single-container:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
25 changes: 12 additions & 13 deletions docker/.env.dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
## Main variables
LOG=INFO
NETWORK=preprod
DB_SCHEMA=preprod
# mainnet, preprod, preview, sanchonet, devkit
PROTOCOL_MAGIC=1
NETWORK_MAGIC=1
# mainnet 764824073, preprod 1, preview 2, sanchonet 4, devkit 42
NETWORK_MAGIC=${PROTOCOL_MAGIC}

# Postgres variables
DB_NAME=rosetta-java
## Postgres variables
DB_NAME=rosetta-java-preprod
DB_USER=rosetta_db_admin
DB_SECRET=weakpwd#123_d
DB_HOST=localhost
DB_PORT=5432
DB_SCHEMA=${NETWORK}

# Cardano node variables
## Cardano node variables
CARDANO_NODE_HOST=localhost
CARDANO_NODE_PORT=3001
CARDANO_NODE_VERSION=8.9.0
CARDANO_NODE_SUBMIT_HOST=cardano-submit-api
CARDANO_NODE_SUBMIT_HOST=localhost
NODE_SUBMIT_API_PORT=8090
CARDANO_NODE_SOCKET_PATH=./node-ipc
CARDANO_NODE_SOCKET=${CARDANO_NODE_SOCKET_PATH}/node.socket
# Api env
CARDANO_NODE_SOCKET_PATH=/node-ipc
CARDANO_NODE_SOCKET=/node-ipc/node.socket
## Api env
API_SPRING_PROFILES_ACTIVE=dev
# staging, h2, test. Additional profiles: mempool (if mempool should be activated)
API_PORT=8081
API_PORT=8080

ROSETTA_VERSION=1.4.13
TOPOLOGY_FILEPATH=/current/topology.json
GENESIS_SHELLEY_PATH=/current/shelley-genesis.json
GENESIS_BYRON_PATH=/current/byron-genesis.json
GENESIS_ALONZO_PATH=/current/alonzo-genesis.json
GENESIS_CONWAY_PATH=/current/conway-genesis.json
API_NODE_SOCKET_PATH=./node/node.socket

PRINT_EXCEPTION=true

## Yaci Indexer env
Expand All @@ -42,3 +40,4 @@ YACI_SPRING_PROFILES=postgres
INDEXER_NODE_PORT=3001
MEMPOOL_ENABLED=false
# Haven't implemented yet
INITIAL_BALANCE_CALCULATION_BLOCK=0
3 changes: 1 addition & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ 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
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 All @@ -170,7 +170,6 @@ COPY ./config /config
RUN mkdir /current

RUN mkdir -p /data/db
RUN mkdir /ipc

# Copy jars
COPY --from=java-builder /root/app/api/target/*.jar /api/app.jar
Expand Down
3 changes: 2 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
echo "entrypoint - run node"
cp -r /config/${NETWORK}/* /current/
mkdir ${CARDANO_NODE_SOCKET_PATH}
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 &
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 ${NETWORK_MAGIC} > /logs/submit-api.log &

echo "entrypoint - run postgres"
/etc/init.d/postgresql start
Expand Down
6 changes: 3 additions & 3 deletions docker/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The build can take up to 1.5 hours.

### 2. Run
````
docker run --env-file .\docker\.env.dockerfile -p 8081:8081 -it {image_name}:latest
docker run --env-file .\docker\.env.dockerfile -p 8080:8080 -it {image_name}:latest
````
We need to specify the path to the environment variables file and open the port.

Expand Down Expand Up @@ -47,15 +47,15 @@ PG_VERSION=14

### 5. Volume with Cardano node data
````
docker run --env-file .\docker\.env.dockerfile -p 8081:8081 -v {custom_folder}:/data/db -it {image_name}:latest
docker run --env-file .\docker\.env.dockerfile -p 8080:8080 -v {custom_folder}:/data/db -it {image_name}:latest
````
It is possible to root the cardano node data volumetrically to the /data/db point.

We can mount a volume with Cardano node data to ``/data/db`` to prevent loading during initialization.

### 6. Volume with custom network configurations
````
docker run --env-file .\docker\.env.dockerfile -p 8081:8081 -v {custom_folder}:/config -it {image_name}:latest
docker run --env-file .\docker\.env.dockerfile -p 8080:8080 -v {custom_folder}:/config -it {image_name}:latest
````
The cardano node configuration json's are stored in the ``config`` folder and copied into the image on build.
If we want to use a custom configuration without rebuilding the image, we can mount a volume with configs to ``/config``
Expand Down

0 comments on commit 9c81095

Please sign in to comment.