From a3b270de5468035c0466923660959acb2fe4f7c5 Mon Sep 17 00:00:00 2001 From: IAvecilla Date: Tue, 16 Jan 2024 15:17:29 -0300 Subject: [PATCH] Move every docker related config file to the project root --- node/Dockerfile => Dockerfile | 6 ++--- Makefile | 41 +++++++++++++++++++++++++++++ node/compose.yaml => compose.yaml | 0 node/entrypoint.sh => entrypoint.sh | 0 node/tools/Makefile | 34 ------------------------ 5 files changed, 44 insertions(+), 37 deletions(-) rename node/Dockerfile => Dockerfile (79%) create mode 100644 Makefile rename node/compose.yaml => compose.yaml (100%) rename node/entrypoint.sh => entrypoint.sh (100%) delete mode 100644 node/tools/Makefile diff --git a/node/Dockerfile b/Dockerfile similarity index 79% rename from node/Dockerfile rename to Dockerfile index 88a81d99..4676cb3d 100644 --- a/node/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ # Build Stage FROM rust:1.72.1 as build -COPY . /node/ +COPY /node/ Makefile /node/ WORKDIR /node RUN apt-get update && apt-get install -y libclang-dev RUN cargo build --release -RUN cd tools && make docker_node_configs +RUN make docker_node_configs # Runtime Stage FROM debian:stable-slim as runtime COPY --from=build /node/target/release/executor /node/ COPY --from=build /node/tools/docker-config/node-configs /node/ -COPY --from=build /node/entrypoint.sh /node/ +COPY entrypoint.sh /node/ WORKDIR /node RUN chmod +x entrypoint.sh diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..f4f28292 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +.PHONY: node node_configs docker_node_configs node_docker consenus_docker_example clean clean_docker +IP?=127.0.0.1:3054 +DOCKER_IP=172.12.0.10 +EXECUTABLE_NODE_DIR=node/tools + +# Locally run commands + +node: + export RUST_LOG=INFO && cd ${EXECUTABLE_NODE_DIR}/node-configs/${IP} && cargo run -- --database ../../database/${IP} + +node_configs: + cd ${EXECUTABLE_NODE_DIR} && cargo run --bin localnet_config -- --input-addrs addresses.txt --output-dir node-configs + +# Docker commands + +docker_node_configs: + cd tools && cargo run --release --bin localnet_config -- --input-addrs docker-config/addresses.txt --output-dir docker-config/node-configs + +node_docker: + mkdir -p ${EXECUTABLE_NODE_DIR}/docker-config + cd ${EXECUTABLE_NODE_DIR}/docker-config && rm -rf addresses.txt && echo ${DOCKER_IP}:3054 >> addresses.txt + docker-compose up -d node-1 + +consenus_docker_example: + mkdir -p ${EXECUTABLE_NODE_DIR}/docker-config + cd ${EXECUTABLE_NODE_DIR}/docker-config && rm -rf addresses.txt && touch addresses.txt && echo 172.12.0.10:3054 >> addresses.txt && echo 172.12.0.11:3054 >> addresses.txt + docker-compose up -d + +# Clean commands + +clean: clean_docker + rm -rf ${EXECUTABLE_NODE_DIR}/node-configs + rm -rf ${EXECUTABLE_NODE_DIR}/database + +clean_docker: + rm -rf ${EXECUTABLE_NODE_DIR}/docker-config + docker rm -f consensus-node + docker rm -f consensus-node-1 + docker rm -f consensus-node-2 + docker network rm -f node-net + docker image rm -f consensus-node diff --git a/node/compose.yaml b/compose.yaml similarity index 100% rename from node/compose.yaml rename to compose.yaml diff --git a/node/entrypoint.sh b/entrypoint.sh similarity index 100% rename from node/entrypoint.sh rename to entrypoint.sh diff --git a/node/tools/Makefile b/node/tools/Makefile deleted file mode 100644 index aae1619f..00000000 --- a/node/tools/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: run-node node-configs clean -IP?=127.0.0.1:3054 -DOCKER_IP=172.12.0.10 - -node: - export RUST_LOG=INFO && cd node-configs/${IP} && cargo run -- --database ./database/${IP} - -node_configs: - cargo run --bin localnet_config -- --input-addrs addresses.txt --output-dir node-configs - -docker_node_configs: - cargo run --release --bin localnet_config -- --input-addrs docker-config/addresses.txt --output-dir docker-config/node-configs - -node_docker: - mkdir -p docker-config - cd docker-config && rm -rf addresses.txt && echo ${DOCKER_IP}:3054 >> addresses.txt - cd .. && docker-compose up -d node-1 - -consenus_docker_example: - mkdir -p docker-config - cd docker-config && rm -rf addresses.txt && touch addresses.txt && echo 172.12.0.10:3054 >> addresses.txt && echo 172.12.0.11:3054 >> addresses.txt - cd .. && docker-compose up -d - -clean: clean_docker - rm -rf node-configs - rm -rf database - -clean_docker: - rm -rf docker-config - docker rm -f consensus-node - docker rm -f consensus-node-1 - docker rm -f consensus-node-2 - docker network rm -f node-net - docker image rm -f consensus-node