From 23ada3e4575a1c6cb52cdfbf16e67e098a296993 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Tue, 16 Apr 2024 12:32:21 -0700 Subject: [PATCH] feat: Parameterize the orb-ns Docker image so that ENV can be used to customize more arguments. (#889) --- images/orb-ns/Dockerfile | 9 +++++++-- images/orb-ns/start.sh | 25 +++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/images/orb-ns/Dockerfile b/images/orb-ns/Dockerfile index 8a8acc9e6..4ddf6a932 100644 --- a/images/orb-ns/Dockerfile +++ b/images/orb-ns/Dockerfile @@ -6,7 +6,7 @@ COPY "./Cargo.toml" "./Cargo.lock" . COPY ./rust ./rust RUN apt-get update && apt-get install -y libssl-dev protobuf-compiler cmake jq binaryen -RUN cargo build --release +RUN cargo build --bin orb-ns --release FROM docker.io/ubuntu:latest @@ -14,7 +14,12 @@ RUN useradd -ms /bin/bash dhtuser USER dhtuser WORKDIR /home/dhtuser -ENV RUST_LOG="info,tower_http,noosphere,noosphere_ns,noosphere_ipfs,noosphere_storage,noosphere_core,noosphere_storage,orb_ns=debug" +ENV RUST_LOG="info,orb_ns=debug" +ENV NOOSPHERE_LOG="academic" +ENV KEY_NAME="ephemeral" +ENV P2P_ADDRESS="0.0.0.0:6666" +ENV API_ADDRESS="0.0.0.0:6667" +ENV IPFS_URL="http://127.0.0.1:5001" COPY --from=builder /noosphere/target/release/orb-ns /usr/bin/orb-ns COPY --chown=dhtuser:dhtuser ./images/orb-ns/start.sh /home/dhtuser/start.sh diff --git a/images/orb-ns/start.sh b/images/orb-ns/start.sh index c0c25cb01..938ce52f9 100755 --- a/images/orb-ns/start.sh +++ b/images/orb-ns/start.sh @@ -2,31 +2,28 @@ set -x MOUNT_DIR="/home/dhtuser/.noosphere" - -KEY=$1 -CONFIG_FILE=$2 +ORB_NS="/usr/bin/orb-ns" cd /home/dhtuser -if [[ "$KEY" = "ephemeral" ]]; then +if [[ "$KEY_NAME" = "ephemeral" ]]; then # This has a side effect of ensuring a ~/.noosphere/keys directory # exists to store the key, circumventing the need for mounting - orb-ns key-gen --key ephemeral + $ORB_NS key-gen --key ephemeral fi if [[ ! -d "$MOUNT_DIR" ]]; then echo "Missing mount on $MOUNT_DIR." exit 1 fi -if [[ -z "$1" ]]; then - echo "ARGS: KEY CONFIG_FILE" - exit 1 -fi -if [[ -z "$2" ]]; then - echo "Missing config file path." - exit 1 -fi echo "RUST_LOG=${RUST_LOG}" echo "NOOSPHERE_LOG=${NOOSPHERE_LOG}" +echo "KEY_NAME=${KEY_NAME}" +echo "P2P_ADDRESS=${P2P_ADDRESS}" +echo "API_ADDRESS=${API_ADDRESS}" +echo "IPFS_URL=${IPFS_URL}" -orb-ns run --config $CONFIG_FILE +$ORB_NS run --key "${KEY_NAME}" \ + --listening-address "${P2P_ADDRESS}" \ + --api-address "${API_ADDRESS}" \ + --ipfs-api-url "${IPFS_URL}"