Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: georgi-l95 <[email protected]>
  • Loading branch information
georgi-l95 committed Dec 19, 2024
1 parent 17d07b8 commit d654cec
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 56 deletions.
36 changes: 20 additions & 16 deletions simulator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,26 @@ tasks.named("processResources") { dependsOn(tasks.named("untarTestBlockStream"))

tasks.named("sourcesJar") { dependsOn(tasks.named("untarTestBlockStream")) }

// Task to prepare and run Docker container
tasks.register("startDockerContainer") {
description = "Prepare and run the simulator containers in publisher and consumer mode"
group = "docker"

doLast {
exec { commandLine("./docker/prepare-docker.sh") }

exec {
workingDir("docker")
commandLine("sh", "-c", "docker compose -p simulator up --build -d")
}
// Vals
val dockerProjectRootDirectory: Directory = layout.projectDirectory.dir("docker")
val dockerBuildRootDirectory: Directory = layout.buildDirectory.dir("docker").get()

// Docker related tasks
val copyDockerFolder: TaskProvider<Copy> =
tasks.register<Copy>("copyDockerFolder") {
description = "Copies the docker folder to the build root directory"
group = "docker"

from(dockerProjectRootDirectory)
into(dockerBuildRootDirectory)
}

exec { commandLine("./docker/cleanup-docker.sh") }
val startDockerContainer: TaskProvider<Exec> =
tasks.register<Exec>("startDockerContainer") {
description = "Creates the docker image of the Block Stream Simulator"
group = "docker"

println("βœ… Docker simulator is now running!")
println("🧹 Build artifacts have been cleaned up")
dependsOn(copyDockerFolder, tasks.assemble)
workingDir(dockerBuildRootDirectory)
commandLine("sh", "-c", "./prepare-docker.sh")
}
}
23 changes: 0 additions & 23 deletions simulator/docker/cleanup-docker.sh

This file was deleted.

20 changes: 12 additions & 8 deletions simulator/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ services:
image: hedera-block-simulator:latest
networks:
- block-node_default
env_file:
- .env
environment:
- GRPC_SERVER_ADDRESS=block-node-server
- BLOCK_STREAM_SIMULATOR_MODE=PUBLISHER
- PROMETHEUS_ENDPOINT_ENABLED=true
- PROMETHEUS_ENDPOINT_PORT_NUMBER=9998
- GRPC_SERVER_ADDRESS=${GRPC_SERVER_ADDRESS}
- BLOCK_STREAM_SIMULATOR_MODE=${PUBLISHER_BLOCK_STREAM_SIMULATOR_MODE}
- PROMETHEUS_ENDPOINT_ENABLED=${PROMETHEUS_ENDPOINT_ENABLED}
- PROMETHEUS_ENDPOINT_PORT_NUMBER=${PUBLISHER_PROMETHEUS_ENDPOINT_PORT_NUMBER}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9998/metrics"]
interval: 3s
Expand All @@ -28,11 +30,13 @@ services:
image: hedera-block-simulator:latest
networks:
- block-node_default
env_file:
- .env
environment:
- GRPC_SERVER_ADDRESS=block-node-server
- BLOCK_STREAM_SIMULATOR_MODE=CONSUMER
- PROMETHEUS_ENDPOINT_ENABLED=true
- PROMETHEUS_ENDPOINT_PORT_NUMBER=9997
- GRPC_SERVER_ADDRESS=${GRPC_SERVER_ADDRESS}
- BLOCK_STREAM_SIMULATOR_MODE=${CONSUMER_BLOCK_STREAM_SIMULATOR_MODE}
- PROMETHEUS_ENDPOINT_ENABLED=${PROMETHEUS_ENDPOINT_ENABLED}
- PROMETHEUS_ENDPOINT_PORT_NUMBER=${CONSUMER_PROMETHEUS_ENDPOINT_PORT_NUMBER}
depends_on:
simulator-publisher:
condition: service_healthy
Expand Down
17 changes: 8 additions & 9 deletions simulator/docker/prepare-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@ echo "πŸš€ Preparing Docker build environment..."

# Get the script's directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$SCRIPT_DIR/../.."

# Build new distribution
echo "πŸ“¦ Building simulator distribution..."
cd "$PROJECT_ROOT"
./gradlew :simulator:assemble
PROJECT_ROOT="$SCRIPT_DIR/../../.."

# Create docker directory if it doesn't exist
mkdir -p "$SCRIPT_DIR"

# Copy simulator distribution
echo "πŸ“‹ Copying simulator distribution..."
cp simulator/build/distributions/simulator-*.tar "$SCRIPT_DIR/"
cp ../distributions/simulator-*.tar "$SCRIPT_DIR/"

# Copy block data
echo "πŸ“‹ Copying block data..."
cp simulator/src/main/resources/block-0.0.3.tar.gz "$SCRIPT_DIR/"
cp ../../src/main/resources/block-0.0.3.tar.gz "$SCRIPT_DIR/"

# Copy logging properties
echo "πŸ“‹ Copying logging properties..."
cp simulator/src/main/resources/logging.properties "$SCRIPT_DIR/logging.properties"
cp ../../src/main/resources/logging.properties "$SCRIPT_DIR/logging.properties"

echo "βœ… Docker build environment prepared successfully!"

docker compose -p simulator up --build -d

echo "βœ… Docker images successfully built and started!"

0 comments on commit d654cec

Please sign in to comment.