I need a docker-compose YAML file for the dockerized version of RSK node (see here).
It needs to have a volume for the config file and another for the DB.
Both the Dockerfile and docker-compose are important resources in the development and deployment of cloud-native applications. But knowing the difference between docker-compose and the Dockerfile is important. The Dockerfile is used to build images, while docker-compose helps you run them as containers.
Docker Compose is a tool that was developed to help define and share multi-container applications. With Compose, we can create a YAML file to define the services and with a single command, can spin everything up or tear it all down.
Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.
Here it is (example for RSK Testnet Docker):
version: "3"
services:
  rsk-testnet:
    image: testnet:latest
    build:
        context: .
        dockerfile: Dockerfile.Testnet
    restart: always
    volumes:
      - rsk_db:/var/lib/rsk/database
      - rsk_cfg:/etc/rsk
    ports:
      - 4444:4444
      - 50505:50505
volumes:
    rsk_db:
        driver: local
        driver_opts:
            o: bind
            type: none
            device: /rsk/database
    rsk_cfg:
        driver: local
        driver_opts:
            o: bind
            type: none
            device: /rsk/conf
A second aproach will be the following: Maybe, it is better to create a separate volume for the data and not share it with the host. Because of speed.
version: "3.8"
services:
  mainnet:
    build: ./docker/rsk
    container_name: rsk-node-mainnet
    entrypoint: "/usr/bin/java -Dlogback.configurationFile='/etc/rsk/logback.xml' -Drsk.conf.file=/etc/rsk/node.conf -cp /usr/share/rsk/rsk.jar co.rsk.Start > /dev/null 2>&1 &"
    volumes:
      - rsk-node-storage:/data
    #  - ./import:/import
    restart: unless-stopped
    networks:
      - rsk-node-mainnet-network
    ports:
      - '4444:4444'
      - '4445:4445'
      
volumes:
  rsk-node-storage:
    external: true
networks:
  rsk-node-mainnet-network:
    external: true
    name: rsk-node-mainnet-network
And to node.conf:
database.dir = /data/database/mainnet
Probably to be correct, you should copy your own node.conf in dockerfile. Or change the entrypoint parameters and insert node.conf from the host.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With