-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add docker configuration for the simulator (#416)
Signed-off-by: georgi-l95 <[email protected]>
- Loading branch information
1 parent
ac58d0b
commit 287adeb
Showing
8 changed files
with
175 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM eclipse-temurin:21 | ||
|
||
# Create a non-root user and group | ||
ARG UNAME=hedera | ||
ARG UID=2000 | ||
ARG GID=2000 | ||
RUN groupadd -g $GID -o $UNAME | ||
RUN useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME | ||
|
||
WORKDIR /app | ||
|
||
# Copy the distribution and resources | ||
COPY simulator-*.tar ./simulator.tar | ||
COPY logging.properties . | ||
|
||
# Create resources directory and copy block data | ||
RUN mkdir -p src/main/resources | ||
COPY block-0.0.3.tar.gz src/main/resources/ | ||
|
||
# Extract the distribution and block data | ||
RUN tar -xf simulator.tar && \ | ||
rm simulator.tar && \ | ||
cd src/main/resources && \ | ||
tar -xzf block-0.0.3.tar.gz && \ | ||
rm block-0.0.3.tar.gz && \ | ||
cd /app && \ | ||
chown -R $UNAME:$UNAME /app | ||
|
||
# Switch to non-root user | ||
USER $UNAME | ||
|
||
# Run the simulator using the extracted directory name | ||
RUN SIMULATOR_DIR=$(ls -d simulator-*/) && \ | ||
echo "#!/bin/bash\n/app/${SIMULATOR_DIR}bin/simulator" > /app/start.sh && \ | ||
chmod +x /app/start.sh | ||
|
||
ENTRYPOINT ["/app/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
services: | ||
simulator-publisher: | ||
container_name: simulator-publisher | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
image: hedera-block-simulator:latest | ||
networks: | ||
- block-node_default | ||
env_file: | ||
- .env | ||
environment: | ||
- BLOCK_STREAM_SIMULATOR_MODE=${PUBLISHER_BLOCK_STREAM_SIMULATOR_MODE} | ||
- PROMETHEUS_ENDPOINT_PORT_NUMBER=${PUBLISHER_PROMETHEUS_ENDPOINT_PORT_NUMBER} | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:9998/metrics"] | ||
interval: 3s | ||
timeout: 10s | ||
retries: 5 | ||
|
||
simulator-consumer: | ||
container_name: simulator-consumer | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
image: hedera-block-simulator:latest | ||
networks: | ||
- block-node_default | ||
env_file: | ||
- .env | ||
environment: | ||
- BLOCK_STREAM_SIMULATOR_MODE=${CONSUMER_BLOCK_STREAM_SIMULATOR_MODE} | ||
- PROMETHEUS_ENDPOINT_PORT_NUMBER=${CONSUMER_PROMETHEUS_ENDPOINT_PORT_NUMBER} | ||
depends_on: | ||
simulator-publisher: | ||
condition: service_healthy | ||
|
||
networks: | ||
block-node_default: | ||
name: block-node_default | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script creates a '.env' file that is used for docker-compose as input for environment variables | ||
# for the simulator services. | ||
|
||
echo "Creating .env file for simulator services..." | ||
|
||
# Generate .env file with default values | ||
cat > .env << EOL | ||
GRPC_SERVER_ADDRESS=block-node-server | ||
PROMETHEUS_ENDPOINT_ENABLED=true | ||
# For publisher service | ||
PUBLISHER_BLOCK_STREAM_SIMULATOR_MODE=PUBLISHER | ||
PUBLISHER_PROMETHEUS_ENDPOINT_PORT_NUMBER=9998 | ||
# For consumer service | ||
CONSUMER_BLOCK_STREAM_SIMULATOR_MODE=CONSUMER | ||
CONSUMER_PROMETHEUS_ENDPOINT_PORT_NUMBER=9997 | ||
EOL | ||
|
||
# Output the values | ||
echo ".env properties:" | ||
cat .env | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters