Skip to content

Commit

Permalink
chore(build): allow a custom zebrad config file path (#5163)
Browse files Browse the repository at this point in the history
* chore(build): allow a custom `zebrad` config file path

Previous behavior:
The zebrad config file was hardcoded into the Dockerfile, allowing to
change specific values, but not the config file as a whole

Expected behavior:
Allow the user to specify the config file themselves, for example with
the nginx image you can pass -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro

Solution:
Use and ARG, with a default value, to allow the user to change the location
of the zebrad configuration file. This also sets the location under /etc,
honoring The Filesystem Hierarchy Standard (FHS) for linux

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

Co-authored-by: teor <teor@riseup.net>
  • Loading branch information
gustavovalverde and teor2345 authored Sep 15, 2022
1 parent 3421869 commit e48e8e5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ RUN apt-get update && \
ARG CHECKPOINT_SYNC=true
ARG NETWORK=Mainnet

ARG ZEBRA_CONF_PATH=/etc/zebra/zebrad.toml
ENV ZEBRA_CONF_PATH ${ZEBRA_CONF_PATH}

# Build the `zebrad.toml` before starting the container, using the arguments from build
# time, or using the default values set just above.
RUN set -ex; \
Expand All @@ -153,7 +156,7 @@ RUN set -ex; \
echo "cache_dir = '/zebrad-cache'"; \
echo "[tracing]"; \
echo "endpoint_addr = '0.0.0.0:3000'"; \
} > "zebrad.toml"
} > "${ZEBRA_CONF_PATH}"

EXPOSE 3000 8233 18233

Expand All @@ -163,4 +166,4 @@ ENV SHORT_SHA $SHORT_SHA
ARG SENTRY_DSN
ENV SENTRY_DSN ${SENTRY_DSN}

CMD [ "zebrad", "-c", "zebrad.toml", "start" ]
CMD [ "zebrad", "-c", "${ZEBRA_CONF_PATH}", "start" ]

0 comments on commit e48e8e5

Please sign in to comment.