Skip to content

Commit 996448a

Browse files
committed
Steem-in-a-box v2.1.0 Release
- 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.
1 parent e844e89 commit 996448a

File tree

4 files changed

+122
-7
lines changed

4 files changed

+122
-7
lines changed

dkr/Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ RUN pip3 install jinja2
2424
ARG steemd_version=stable
2525
ENV steemd_version ${steemd_version}
2626

27+
ARG STEEM_SOURCE="https://github.com/steemit/steem.git"
28+
ENV STEEM_SOURCE ${STEEM_SOURCE}
29+
2730
ARG STEEM_STATIC_BUILD=ON
2831
ENV STEEM_STATIC_BUILD ${STEEM_STATIC_BUILD}
2932

@@ -40,9 +43,9 @@ ARG SKIP_BY_TX_ID=ON
4043
ENV SKIP_BY_TX_ID ${SKIP_BY_TX_ID}
4144

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

6871
RUN echo "This container has been built with the following options:" >> /steem_build.txt && \
69-
echo "----\nsteemit/steem version/commit: ${steemd_version}\n----" >> /steem_build.txt && \
70-
echo "Default steemd executable: ${STEEMD_BIN}\n----" >> /steem_build.txt && \
72+
echo "----" >> /steem_build.txt && \
73+
echo "Git Repository: ${STEEM_SOURCE}" >> /steem_build.txt && \
74+
echo "Git version/commit: ${steemd_version}\n----" >> /steem_build.txt && \
75+
echo "Default steemd executable: ${STEEMD_BIN}\n---" >> /steem_build.txt && \
76+
echo "--- CMake Config Options ---" >> /steem_build.txt && \
7177
echo "LOW_MEMORY_MODE=${LOW_MEMORY_MODE}\nSTEEM_STATIC_BUILD=${STEEM_STATIC_BUILD}" >> /steem_build.txt && \
7278
echo "SKIP_BY_TX_ID=${SKIP_BY_TX_ID}\nENABLE_MIRA=${ENABLE_MIRA}\nCLEAR_VOTES=${CLEAR_VOTES}" >> /steem_build.txt && \
7379
echo "----\nBuilt at: $(date)\n----" >> /steem_build.txt

dkr_fullnode/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ RUN apt-get update && \
1313

1414
ARG steemd_version=stable
1515

16+
ARG STEEM_SOURCE="https://github.com/steemit/steem.git"
17+
ENV STEEM_SOURCE ${STEEM_SOURCE}
18+
1619
ARG STEEM_STATIC_BUILD=ON
1720
ENV STEEM_STATIC_BUILD ${STEEM_STATIC_BUILD}
1821

1922
ARG ENABLE_MIRA=ON
2023
ENV ENABLE_MIRA ${ENABLE_MIRA}
2124

2225
RUN cd ~ && \
23-
git clone https://github.com/steemit/steem.git && \
26+
git clone ${STEEM_SOURCE} steem && \
2427
cd steem && \
2528
git checkout ${steemd_version} && \
2629
git submodule update --init --recursive && \

example.env

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This is an example .env file containing common environment variables that can be customised
2+
# by the user, to allow steem-docker to be adjusted to the user's specific needs,
3+
# as well as to aid with running multiple instances of steem-docker.
4+
#
5+
# Note: The .env file is loaded by run.sh after several variables are already set.
6+
# This means that you can reference variables such as $DIR (detected folder of run.sh),
7+
# $DATADIR (absolute path to steem-docker/data) etc.
8+
#
9+
#
10+
11+
# Unique name to label the container created by this steem-docker installation
12+
DOCKER_NAME="seed"
13+
14+
# Default docker image to run using ./run.sh start / restart / replay
15+
# Also used when tagging remote image downloaded from ./run.sh install
16+
DOCKER_IMAGE="steem"
17+
18+
# Comma separated port numbers to expose to the internet (binds to 0.0.0.0)
19+
PORTS=2001
20+
# Advanced Usage Example:
21+
#
22+
# Expose 2001 to the internet, but only expose RPC ports 8090 and 8091 onto 127.0.0.1 (localhost)
23+
# allowing the host machine access to the container's RPC ports via 127.0.0.1:8090 and 127.0.0.1:8091
24+
#
25+
# PORTS=2001,127.0.0.1:8090:8090,127.0.0.1:8091:8091
26+
27+
# Amount of time in seconds to allow the docker container to stop before killing it.
28+
# Default: 600 seconds (10 minutes)
29+
STOP_TIME=600
30+
31+
# Websocket RPC node to use by default for ./run.sh remote_wallet
32+
REMOTE_WS="wss://steemd.privex.io"
33+
34+
# Remote docker tags to pull when running ./run.sh install OR ./run.sh install_full with no arguments, respectively
35+
DK_TAG="someguy123/steem:latest"
36+
DK_TAG_FULL="someguy123/steem:latest-full"
37+
38+
# Git repository to use when building Steem - containing steemd code
39+
STEEM_SOURCE="https://github.com/steemit/steem.git"
40+
41+
# LOCAL folder containing Dockerfile for ./run.sh build
42+
DOCKER_DIR="$DIR/dkr"
43+
# LOCAL folder to hold witness_node_data_dir
44+
DATADIR="$DIR/data"
45+
# LOCAL folder to store shared_memory.bin (or rocksdb files for MIRA)
46+
SHM_DIR="/dev/shm"
47+
48+
# blockchain folder, used by dlblocks
49+
BC_FOLDER="$DATADIR/witness_node_data_dir/blockchain"
50+
51+
# Example RocksDB configuration file, will automatically be copied to MIRA_FILE on first run.sh execution
52+
# if MIRA_FILE doesn't exist
53+
EXAMPLE_MIRA="$DATADIR/witness_node_data_dir/database.cfg.example"
54+
MIRA_FILE="$DATADIR/witness_node_data_dir/database.cfg"
55+
56+
# Example Steem node configuration file, will automatically be copied to CONF_FILE on first run.sh execution
57+
# if CONF_FILE doesn't exist
58+
EXAMPLE_CONF="$DATADIR/witness_node_data_dir/config.ini.example"
59+
CONF_FILE="$DATADIR/witness_node_data_dir/config.ini"
60+
61+
# Array of additional arguments to be passed to Docker during builds
62+
# Generally populated using arguments passed to build/build_full
63+
# But you can specify custom additional build parameters by setting BUILD_ARGS
64+
# as an array in .env
65+
# e.g.
66+
#
67+
# BUILD_ARGS=('--rm' '-q' '--compress')
68+
#
69+
BUILD_ARGS=()
70+
71+

run.sh

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
# Released under GNU AGPL by Someguy123
55
#
66

7+
8+
# Error handling function for ShellCore
9+
_sc_fail() { >&2 echo "Failed to load or install Privex ShellCore..." && exit 1; }
10+
# If `load.sh` isn't found in the user install / global install, then download and run the auto-installer
11+
# from Privex's CDN.
12+
[[ -f "${HOME}/.pv-shcore/load.sh" ]] || [[ -f "/usr/local/share/pv-shcore/load.sh" ]] || \
13+
{ curl -fsS https://cdn.privex.io/github/shell-core/install.sh | bash >/dev/null; } || _sc_fail
14+
15+
# Attempt to load the local install of ShellCore first, then fallback to global install if it's not found.
16+
[[ -d "${HOME}/.pv-shcore" ]] && source "${HOME}/.pv-shcore/load.sh" || \
17+
source "/usr/local/share/pv-shcore/load.sh" || _sc_fail
18+
19+
720
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
821
: ${DOCKER_DIR="$DIR/dkr"}
922
: ${FULL_DOCKER_DIR="$DIR/dkr_fullnode"}
@@ -43,7 +56,11 @@ RESET="$(tput sgr0)"
4356
# Default: 600 seconds (10 minutes)
4457
: ${STOP_TIME=600}
4558

46-
# default. override in .env
59+
# Git repository to use when building Steem - containing steemd code
60+
: ${STEEM_SOURCE="https://github.com/steemit/steem.git"}
61+
62+
# Comma separated list of ports to expose to the internet.
63+
# By default, only port 2001 will be exposed (the P2P seed port)
4764
: ${PORTS="2001"}
4865

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

73+
5674
# Array of additional arguments to be passed to Docker during builds
5775
# Generally populated using arguments passed to build/build_full
5876
# But you can specify custom additional build parameters by setting BUILD_ARGS
@@ -138,7 +156,11 @@ IFS=","
138156
DPORTS=()
139157
for i in $PORTS; do
140158
if [[ $i != "" ]]; then
141-
DPORTS+=("-p0.0.0.0:$i:$i")
159+
if grep -q ":" <<< "$i"; then
160+
DPORTS+=("-p$i")
161+
else
162+
DPORTS+=("-p0.0.0.0:$i:$i")
163+
fi
142164
fi
143165
done
144166

@@ -217,13 +239,26 @@ parse_build_args() {
217239
shift; shift; # Get rid of the two tag arguments. Everything after is now build args
218240
fi
219241
fi
242+
local has_steem_src='n'
220243
if (( $# >= 1 )); then
221244
msg yellow " >> Additional build arguments specified."
222245
for a in "$@"; do
223246
msg yellow " ++ Build argument: ${BOLD}${a}"
224247
BUILD_ARGS+=('--build-arg' "$a")
248+
if grep -q 'STEEM_SOURCE' <<< "$a"; then
249+
has_steem_src='y'
250+
fi
225251
done
226252
fi
253+
254+
if [[ "$has_steem_src" == "y" ]]; then
255+
msg bold yellow " [!!] STEEM_SOURCE has been specified in the build arguments. Using source from build args instead of global"
256+
else
257+
msg bold yellow " [!!] Did not find STEEM_SOURCE in build args. Using STEEM_SOURCE from environment:"
258+
msg bold yellow " [!!] STEEM_SOURCE = ${STEEM_SOURCE}"
259+
BUILD_ARGS+=('--build-arg' "STEEM_SOURCE=${STEEM_SOURCE}")
260+
fi
261+
227262
msg blue " ++ CUSTOM BUILD SPECIFIED. Building from branch/tag ${BOLD}${BUILD_VER}"
228263
msg blue " ++ Tagging final image as: ${BOLD}${CUST_TAG}"
229264
msg yellow " -> Docker build arguments: ${BOLD}${BUILD_ARGS[@]}"

0 commit comments

Comments
 (0)