fix(build): a path must exist before creating a file in it (#5177)

* fix(build): a path must exist before creating a file in it

Other directories in the Dockerfile were automatically created with the `WORKDIR` and  `COPY` commands. In this case it has to be explicitly created

* fix(build): use a variable for the conf path and another for the file

Add some pending actions to consider, for a better user experience.

* fix(runtime): run with the correct path
This commit is contained in:
Gustavo Valverde 2022-09-15 18:26:32 -04:00 committed by GitHub
parent d6781de5e6
commit 726f732640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -139,11 +139,21 @@ RUN apt-get update && \
ARG CHECKPOINT_SYNC=true
ARG NETWORK=Mainnet
ARG ZEBRA_CONF_PATH=/etc/zebra/zebrad.toml
# Use a configurable dir and file for the zebrad configuration file
ARG ZEBRA_CONF_PATH=/etc/zebra
ENV ZEBRA_CONF_PATH ${ZEBRA_CONF_PATH}
ARG ZEBRA_CONF_FILE=zebrad.toml
ENV ZEBRA_CONF_FILE ${ZEBRA_CONF_FILE}
# Build the `zebrad.toml` before starting the container, using the arguments from build
# time, or using the default values set just above.
# time, or using the default values set just above. And create the conf path and file if
# it does not exist
#
# TODO: move this file creation to an entrypoint as we can use default values at runtime,
# and modify those as needed when starting the container (at runtime and not at build time)
RUN mkdir -p ${ZEBRA_CONF_PATH} \
&& touch ${ZEBRA_CONF_PATH}/${ZEBRA_CONF_FILE}
RUN set -ex; \
{ \
echo "[consensus]"; \
@ -156,7 +166,7 @@ RUN set -ex; \
echo "cache_dir = '/zebrad-cache'"; \
echo "[tracing]"; \
echo "endpoint_addr = '0.0.0.0:3000'"; \
} > "${ZEBRA_CONF_PATH}"
} > "${ZEBRA_CONF_PATH}/${ZEBRA_CONF_FILE}"
EXPOSE 3000 8233 18233
@ -166,4 +176,5 @@ ENV SHORT_SHA $SHORT_SHA
ARG SENTRY_DSN
ENV SENTRY_DSN ${SENTRY_DSN}
CMD [ "zebrad", "-c", "${ZEBRA_CONF_PATH}", "start" ]
# TODO: remove the specified config file location and use the default expected by zebrad
CMD [ "zebrad", "-c", "${ZEBRA_CONF_PATH}/${ZEBRA_CONF_FILE}", "start" ]