Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Commit

Permalink
feat: Parameterize the orb-ns Docker image so that ENV can be used to…
Browse files Browse the repository at this point in the history
… customize more arguments. (#889)
  • Loading branch information
jsantell committed Apr 16, 2024
1 parent bdf8614 commit 23ada3e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
9 changes: 7 additions & 2 deletions images/orb-ns/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ 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

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
Expand Down
25 changes: 11 additions & 14 deletions images/orb-ns/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 23ada3e

Please sign in to comment.