Skip to content

Commit c7a28e1

Browse files
refactor: enhance documentation and streamline scripts
1 parent 8c2dc6d commit c7a28e1

File tree

2 files changed

+12
-32
lines changed

2 files changed

+12
-32
lines changed

docker/Dockerfile

+9-9
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ ENV CARGO_HOME=${CARGO_HOME}
4646
ARG FEATURES
4747
ENV FEATURES=${FEATURES}
4848

49-
ARG SHORT_SHA
50-
# If this is not set, it must be an empty string, so Zebra can try an alternative git commit source:
49+
# If this is not set, it must be an empty string, so Zebra can try an
50+
# alternative git commit source:
5151
# https://github.com/ZcashFoundation/zebra/blob/9ebd56092bcdfc1a09062e15a0574c94af37f389/zebrad/src/application.rs#L179-L182
52+
ARG SHORT_SHA
5253
ENV SHORT_SHA=${SHORT_SHA:-}
5354

5455
# This stage builds tests without running them.
@@ -79,7 +80,7 @@ RUN addgroup --quiet --gid ${GID} ${USER} && \
7980
WORKDIR ${HOME}
8081

8182
# Build Zebra test binaries, but don't run them
82-
83+
#
8384
# Leverage a cache mount to /usr/local/cargo/registry/
8485
# for downloaded dependencies, a cache mount to /usr/local/cargo/git/db
8586
# for git repository dependencies, and a cache mount to ${HOME}/target/ for
@@ -132,11 +133,10 @@ COPY --chown=${UID}:${GID} ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh
132133

133134
ENTRYPOINT [ "entrypoint.sh", "test" ]
134135

135-
# In this stage we build a release (generate the zebrad binary)
136+
# This stage builds the zebrad release binary.
136137
#
137-
# This step also adds `cache mounts` as this stage is completely independent from the
138-
# `test` stage. This step is a dependency for the `runtime` stage, which uses the resulting
139-
# zebrad binary from this step.
138+
# It also adds `cache mounts` as this stage is completely independent from the
139+
# `test` stage. The resulting zebrad binary is used in the `runtime` stage.
140140
FROM deps AS release
141141

142142
ARG HOME
@@ -163,8 +163,8 @@ RUN --mount=type=bind,source=tower-batch-control,target=tower-batch-control \
163163
cargo build --locked --release --features "${FEATURES}" --package zebrad --bin zebrad && \
164164
cp ${HOME}/target/release/zebrad /usr/local/bin
165165

166-
# This step starts from scratch using Debian and only adds the resulting binary
167-
# from the `release` stage.
166+
# This stage starts from scratch using Debian and copies the built zebrad binary
167+
# from the `release` stage along with other binaries and files.
168168
FROM debian:bookworm-slim AS runtime
169169

170170
ARG FEATURES

docker/entrypoint.sh

+3-23
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if [[ ! -f "${ZEBRA_CONF_PATH}" ]]; then
2626
exit 1
2727
fi
2828

29-
# Use gosu to drop privileges
29+
# Use gosu to drop privileges and execute the given command as the specified UID:GID
3030
exec_as_user() {
3131
exec gosu "${UID}:${GID}" "$@"
3232
}
@@ -105,26 +105,6 @@ prepare_conf_file() {
105105
echo "${ZEBRA_CONF_PATH}"
106106
}
107107

108-
# Checks if a directory contains subdirectories
109-
#
110-
# Exits with 0 if it does, and 1 otherwise.
111-
check_directory_files() {
112-
local dir="$1"
113-
# Check if the directory exists
114-
if [[ -d "${dir}" ]]; then
115-
# Check if there are any subdirectories
116-
if find "${dir}" -mindepth 1 -type d | read -r; then
117-
:
118-
else
119-
echo "No subdirectories found in ${dir}."
120-
exit 1
121-
fi
122-
else
123-
echo "Directory ${dir} does not exist."
124-
exit 1
125-
fi
126-
}
127-
128108
# Runs cargo test with an arbitrary number of arguments.
129109
#
130110
# ## Positional Parameters
@@ -164,7 +144,7 @@ run_cargo_test() {
164144

165145
# Runs tests depending on the env vars.
166146
#
167-
# Positional Parameters
147+
# ## Positional Parameters
168148
#
169149
# - $@: Arbitrary command that will be executed if no test env var is set.
170150
run_tests() {
@@ -290,7 +270,7 @@ echo "Prepared the following Zebra config:"
290270
cat "${ZEBRA_CONF_PATH}"
291271

292272
# - If "$1" is "--", "-", or "zebrad", run `zebrad` with the remaining params.
293-
# - If "$1" is "tests":
273+
# - If "$1" is "test":
294274
# - and "$2" is "zebrad", run `zebrad` with the remaining params,
295275
# - else run tests with the remaining params.
296276
# - TODO: If "$1" is "monitoring", start a monitoring node.

0 commit comments

Comments
 (0)