Skip to content

Commit

Permalink
Steem-in-a-box v2.1.0 Release
Browse files Browse the repository at this point in the history
 - Added `example.env` file, showing various .env options that can be configured

- Added `STEEM_SOURCE` build argument to `dkr/Dockerfile` and `dkr_full/Dockerfile` - this allows for
   the default Git repository to be changed if needed, e.g. building forks / testing changes made on personal fork

**Changes to run.sh**

 - Now uses [Privex ShellCore](https://github.com/Privex/shell-core), so I don't have to keep copy-pasting
   code snippets into the project.

- Added `STEEM_SOURCE` env var which can be overrided using `export STEEM_SOURCE=xxx` or by adding the
   config option to `.env`

- `build()` supports STEEM_SOURCE as both a build arg, and env fallback.
    - First checks if `STEEM_SOURCE` was specified in the CLI build arguments
    - If it was specified in the CLI build arguments, then that takes precedence and the env var `STEEM_SOURCE` will be ignored.
    - If it WASN'T specified in the build arguments, it will add a build argument for STEEM_SOURCE using the env var `STEEM_SOURCE`

- The env option `PORTS` now supports the more specific `1.2.3.4:8090:8090` format, allowing for exposing ports only on localhost,
   or only for a specific external IP address etc.
  • Loading branch information
Someguy123 committed Feb 24, 2020
1 parent e844e89 commit 996448a
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 7 deletions.
14 changes: 10 additions & 4 deletions dkr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ RUN pip3 install jinja2
ARG steemd_version=stable
ENV steemd_version ${steemd_version}

ARG STEEM_SOURCE="https://github.com/steemit/steem.git"
ENV STEEM_SOURCE ${STEEM_SOURCE}

ARG STEEM_STATIC_BUILD=ON
ENV STEEM_STATIC_BUILD ${STEEM_STATIC_BUILD}

Expand All @@ -40,9 +43,9 @@ ARG SKIP_BY_TX_ID=ON
ENV SKIP_BY_TX_ID ${SKIP_BY_TX_ID}

RUN cd ~ && \
git clone https://github.com/steemit/steem.git && \
echo " >>> Cloning tag/branch ${steemd_version} from repo: ${STEEM_SOURCE}" && \
git clone ${STEEM_SOURCE} steem -b ${steemd_version} && \
cd steem && \
git checkout ${steemd_version} && \
git submodule update --init --recursive && \
cd ~/steem && \
cmake -DCMAKE_BUILD_TYPE=Release . \
Expand All @@ -66,8 +69,11 @@ ARG STEEMD_BIN="/usr/local/bin/steemd"
ENV STEEMD_BIN ${STEEMD_BIN}

RUN echo "This container has been built with the following options:" >> /steem_build.txt && \
echo "----\nsteemit/steem version/commit: ${steemd_version}\n----" >> /steem_build.txt && \
echo "Default steemd executable: ${STEEMD_BIN}\n----" >> /steem_build.txt && \
echo "----" >> /steem_build.txt && \
echo "Git Repository: ${STEEM_SOURCE}" >> /steem_build.txt && \
echo "Git version/commit: ${steemd_version}\n----" >> /steem_build.txt && \
echo "Default steemd executable: ${STEEMD_BIN}\n---" >> /steem_build.txt && \
echo "--- CMake Config Options ---" >> /steem_build.txt && \
echo "LOW_MEMORY_MODE=${LOW_MEMORY_MODE}\nSTEEM_STATIC_BUILD=${STEEM_STATIC_BUILD}" >> /steem_build.txt && \
echo "SKIP_BY_TX_ID=${SKIP_BY_TX_ID}\nENABLE_MIRA=${ENABLE_MIRA}\nCLEAR_VOTES=${CLEAR_VOTES}" >> /steem_build.txt && \
echo "----\nBuilt at: $(date)\n----" >> /steem_build.txt
Expand Down
5 changes: 4 additions & 1 deletion dkr_fullnode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ RUN apt-get update && \

ARG steemd_version=stable

ARG STEEM_SOURCE="https://github.com/steemit/steem.git"
ENV STEEM_SOURCE ${STEEM_SOURCE}

ARG STEEM_STATIC_BUILD=ON
ENV STEEM_STATIC_BUILD ${STEEM_STATIC_BUILD}

ARG ENABLE_MIRA=ON
ENV ENABLE_MIRA ${ENABLE_MIRA}

RUN cd ~ && \
git clone https://github.com/steemit/steem.git && \
git clone ${STEEM_SOURCE} steem && \
cd steem && \
git checkout ${steemd_version} && \
git submodule update --init --recursive && \
Expand Down
71 changes: 71 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This is an example .env file containing common environment variables that can be customised
# by the user, to allow steem-docker to be adjusted to the user's specific needs,
# as well as to aid with running multiple instances of steem-docker.
#
# Note: The .env file is loaded by run.sh after several variables are already set.
# This means that you can reference variables such as $DIR (detected folder of run.sh),
# $DATADIR (absolute path to steem-docker/data) etc.
#
#

# Unique name to label the container created by this steem-docker installation
DOCKER_NAME="seed"

# Default docker image to run using ./run.sh start / restart / replay
# Also used when tagging remote image downloaded from ./run.sh install
DOCKER_IMAGE="steem"

# Comma separated port numbers to expose to the internet (binds to 0.0.0.0)
PORTS=2001
# Advanced Usage Example:
#
# Expose 2001 to the internet, but only expose RPC ports 8090 and 8091 onto 127.0.0.1 (localhost)
# allowing the host machine access to the container's RPC ports via 127.0.0.1:8090 and 127.0.0.1:8091
#
# PORTS=2001,127.0.0.1:8090:8090,127.0.0.1:8091:8091

# Amount of time in seconds to allow the docker container to stop before killing it.
# Default: 600 seconds (10 minutes)
STOP_TIME=600

# Websocket RPC node to use by default for ./run.sh remote_wallet
REMOTE_WS="wss://steemd.privex.io"

# Remote docker tags to pull when running ./run.sh install OR ./run.sh install_full with no arguments, respectively
DK_TAG="someguy123/steem:latest"
DK_TAG_FULL="someguy123/steem:latest-full"

# Git repository to use when building Steem - containing steemd code
STEEM_SOURCE="https://github.com/steemit/steem.git"

# LOCAL folder containing Dockerfile for ./run.sh build
DOCKER_DIR="$DIR/dkr"
# LOCAL folder to hold witness_node_data_dir
DATADIR="$DIR/data"
# LOCAL folder to store shared_memory.bin (or rocksdb files for MIRA)
SHM_DIR="/dev/shm"

# blockchain folder, used by dlblocks
BC_FOLDER="$DATADIR/witness_node_data_dir/blockchain"

# Example RocksDB configuration file, will automatically be copied to MIRA_FILE on first run.sh execution
# if MIRA_FILE doesn't exist
EXAMPLE_MIRA="$DATADIR/witness_node_data_dir/database.cfg.example"
MIRA_FILE="$DATADIR/witness_node_data_dir/database.cfg"

# Example Steem node configuration file, will automatically be copied to CONF_FILE on first run.sh execution
# if CONF_FILE doesn't exist
EXAMPLE_CONF="$DATADIR/witness_node_data_dir/config.ini.example"
CONF_FILE="$DATADIR/witness_node_data_dir/config.ini"

# Array of additional arguments to be passed to Docker during builds
# Generally populated using arguments passed to build/build_full
# But you can specify custom additional build parameters by setting BUILD_ARGS
# as an array in .env
# e.g.
#
# BUILD_ARGS=('--rm' '-q' '--compress')
#
BUILD_ARGS=()


39 changes: 37 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
# Released under GNU AGPL by Someguy123
#


# Error handling function for ShellCore
_sc_fail() { >&2 echo "Failed to load or install Privex ShellCore..." && exit 1; }
# If `load.sh` isn't found in the user install / global install, then download and run the auto-installer
# from Privex's CDN.
[[ -f "${HOME}/.pv-shcore/load.sh" ]] || [[ -f "/usr/local/share/pv-shcore/load.sh" ]] || \
{ curl -fsS https://cdn.privex.io/github/shell-core/install.sh | bash >/dev/null; } || _sc_fail

# Attempt to load the local install of ShellCore first, then fallback to global install if it's not found.
[[ -d "${HOME}/.pv-shcore" ]] && source "${HOME}/.pv-shcore/load.sh" || \
source "/usr/local/share/pv-shcore/load.sh" || _sc_fail


DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
: ${DOCKER_DIR="$DIR/dkr"}
: ${FULL_DOCKER_DIR="$DIR/dkr_fullnode"}
Expand Down Expand Up @@ -43,7 +56,11 @@ RESET="$(tput sgr0)"
# Default: 600 seconds (10 minutes)
: ${STOP_TIME=600}

# default. override in .env
# Git repository to use when building Steem - containing steemd code
: ${STEEM_SOURCE="https://github.com/steemit/steem.git"}

# Comma separated list of ports to expose to the internet.
# By default, only port 2001 will be exposed (the P2P seed port)
: ${PORTS="2001"}

# Internal variable. Set to 1 by build_full to inform child functions
Expand All @@ -53,6 +70,7 @@ CUST_TAG="steem"
# Placeholder for BUILD_VER shared between functions
BUILD_VER=""


# Array of additional arguments to be passed to Docker during builds
# Generally populated using arguments passed to build/build_full
# But you can specify custom additional build parameters by setting BUILD_ARGS
Expand Down Expand Up @@ -138,7 +156,11 @@ IFS=","
DPORTS=()
for i in $PORTS; do
if [[ $i != "" ]]; then
DPORTS+=("-p0.0.0.0:$i:$i")
if grep -q ":" <<< "$i"; then
DPORTS+=("-p$i")
else
DPORTS+=("-p0.0.0.0:$i:$i")
fi
fi
done

Expand Down Expand Up @@ -217,13 +239,26 @@ parse_build_args() {
shift; shift; # Get rid of the two tag arguments. Everything after is now build args
fi
fi
local has_steem_src='n'
if (( $# >= 1 )); then
msg yellow " >> Additional build arguments specified."
for a in "$@"; do
msg yellow " ++ Build argument: ${BOLD}${a}"
BUILD_ARGS+=('--build-arg' "$a")
if grep -q 'STEEM_SOURCE' <<< "$a"; then
has_steem_src='y'
fi
done
fi

if [[ "$has_steem_src" == "y" ]]; then
msg bold yellow " [!!] STEEM_SOURCE has been specified in the build arguments. Using source from build args instead of global"
else
msg bold yellow " [!!] Did not find STEEM_SOURCE in build args. Using STEEM_SOURCE from environment:"
msg bold yellow " [!!] STEEM_SOURCE = ${STEEM_SOURCE}"
BUILD_ARGS+=('--build-arg' "STEEM_SOURCE=${STEEM_SOURCE}")
fi

msg blue " ++ CUSTOM BUILD SPECIFIED. Building from branch/tag ${BOLD}${BUILD_VER}"
msg blue " ++ Tagging final image as: ${BOLD}${CUST_TAG}"
msg yellow " -> Docker build arguments: ${BOLD}${BUILD_ARGS[@]}"
Expand Down

0 comments on commit 996448a

Please sign in to comment.