Skip to content

Commit

Permalink
ADD docker support (#17)
Browse files Browse the repository at this point in the history
ADD docker support
  • Loading branch information
y4ssi authored Sep 25, 2024
1 parent eca507a commit 996f05f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM debian:12 AS builder
COPY . /srv/
RUN apt update
RUN apt -y install build-essential libboost-all-dev libssl-dev
WORKDIR /srv
RUN make

FROM debian:12
RUN apt update && \
apt install -y libssl3 --no-install-recommends && \
apt clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /home/dnsseed
COPY --from=builder /srv/dnsseed /home/dnsseed/
COPY entrypoint.sh /

# Set the entrypoint to your script
ENTRYPOINT ["/entrypoint.sh"]

# Default CMD if no arguments are provided (this can be overwritten at runtime)
CMD ["/home/dnsseed/dnsseed"]
35 changes: 35 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -ex

# Default values for environment variables if not set
export SEED_HOSTNAME=${SEED_HOSTNAME}
export NODE_HOSTNAME=${NODE_HOSTNAME}
export EMAIL=${EMAIL}
export THREADS=${THREADS}
export ADDRESS=${ADDRESS:-"0.0.0.0"}
export PORT=${PORT:-"53"}
export NETWORK=${NETWORK:-"mainnet"} # Default to "mainnet" unless otherwise set

# Extra arguments for testnet
extra_args=""
if [[ "$NETWORK" == "testnet" ]]; then
export extra_args="--testnet"
fi

# If the first argument starts with a hyphen (-), consider it an argument for the dnsseed binary
if [[ "${1:0:1}" == "-" ]]; then
exec /home/dnsseed/dnsseed "$@"
fi

# Run the dnsseed binary with default arguments and extra_args, or run another command if provided
if [ "$1" == "/home/dnsseed/dnsseed" ]; then
exec /home/dnsseed/dnsseed -h "$SEED_HOSTNAME" \
-n "$NODE_HOSTNAME" \
-a "$ADDRESS" \
-p "$PORT" \
-m "$EMAIL" \
-t "$THREADS" "$extra_args"
else
# If another command is passed, run that instead
exec "$@"
fi

0 comments on commit 996f05f

Please sign in to comment.