As a senior software developer specializing in blockchain and Rust, I'll provide you with a suggested approach to manage and develop Blockscout-RS microservices locally.
Prerequisites
- You have both repositories cloned in separate folders:
blockscout and blockscout-rs
- You have a local blockchain setup (e.g., using
golembase-op-geth)
- You have Rust and Elixir installed on your machine
Step 1: Create a local development environment for Blockscout-RS
In the blockscout-rs folder, create a new branch or checkout the master branch to ensure you have the latest changes.
Create a new file named docker-compose.yml in the blockscout-rs folder with the following content:
version: '3'
services:
indexer:
build: .
environment:
- DATABASE_URL=postgres://user:password@localhost:5432/database
- CHAIN_ID=your_chain_id
ports:
- "8080:8080"
depends_on:
- postgres
postgres:
image: postgres:13
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=database
volumes:
- ./pg-data:/var/lib/postgresql/data
# Add other microservices you want to run locally
# For example:
# api:
# build: .
# environment:
# - DATABASE_URL=postgres://user:password@localhost:5432/database
# - CHAIN_ID=your_chain_id
# ports:
# - "8081:8081"
This docker-compose file will allow you to run the indexer microservice and a Postgres database locally.
Step 2: Configure Blockscout-RS to run locally
In the blockscout-rs folder, create a new file named .env with the following content:
DATABASE_URL=postgres://user:password@localhost:5432/database
CHAIN_ID=your_chain_id
Update the CHAIN_ID variable to match your local blockchain's chain ID.
Step 3: Build and run Blockscout-RS microservices locally
Run the following command in the blockscout-rs folder:
docker-compose up -d
This will build and start the indexer microservice and Postgres database in detached mode.
Step 4: Run specific microservices
To run only the essential microservices, you can modify the docker-compose.yml file to include only the services you need. For example, if you only want to run the indexer and API microservices, update the file to:
version: '3'
services:
indexer:
build: .
environment:
- DATABASE_URL=postgres://user:password@localhost:5432/database
- CHAIN_ID=your_chain_id
ports:
- "8080:8080"
depends_on:
- postgres
api:
build: .
environment:
- DATABASE_URL=postgres://user:password@localhost:5432/database
- CHAIN_ID=your_chain_id
ports:
- "8081:8081"
depends_on:
- postgres
Then, run docker-compose up -d again to start the services.
Step 5: Connect to your local blockchain
Update the CHAIN_ID variable in the .env file to match your local blockchain's chain ID.
You can now use tools like curl or a blockchain explorer to interact with your local blockchain and test the Blockscout-RS microservices.
Step 6: Develop and test new features
As you develop new features or make changes to the existing codebase, you can run the microservices locally and test them using your local blockchain.
Managing dependencies with Blockscout
Since you won't be changing the Elixir indexer code, you can focus on developing and testing the Blockscout-RS microservices independently.
When you need to integrate changes with the Elixir indexer, you can merge your changes into the blockscout-rs repository and coordinate with the team to integrate the changes with the Elixir indexer.
By following these steps, you should be able to quickly change and manage Blockscout-RS microservices locally, run only the essential ones, and work with your local blockchain and data.