Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(holesky): image and env sourcing in docker setup #525

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bolt-sidecar/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Opts {
fn read_env_file() -> eyre::Result<()> {
match dotenvy::dotenv() {
// It means the .env file hasn't been found but it's okay since it's optional
Err(dotenvy::Error::Io(_)) => (),
Err(dotenvy::Error::Io(_)) => println!("No .env file found, using environment variables"),
Err(err) => bail!("Failed to load .env file: {:?}", err),
Ok(path) => println!("Loaded environment variables from path: {:?}", path),
};
Expand Down
2 changes: 1 addition & 1 deletion testnets/holesky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ First, make sure to have [Docker](https://docs.docker.com/engine/install/),
Then clone the Bolt repository by running:

```bash
git clone --branch v0.3.0-alpha htts://github.com/chainbound/bolt.git
git clone htts://github.com/chainbound/bolt.git
cd bolt/testnets/holesky
```

Expand Down
9 changes: 7 additions & 2 deletions testnets/holesky/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
services:
bolt-sidecar-holesky:
image: ghcr.io/chainbound/bolt-sidecar:v0.3.0-alpha
image: ghcr.io/chainbound/bolt-sidecar:v0.3.1-alpha.rc1
container_name: bolt-sidecar-holesky
restart: unless-stopped
env_file: ./bolt-sidecar.env
ports:
# NOTE: to read these envs, it is necessary to provide them via `--env-file` or having them already set.
- "${BOLT_SIDECAR_PORT:-8017}:${BOLT_SIDECAR_PORT:-8017}" # This port should be opened on your firewall!
- "${BOLT_SIDECAR_CONSTRAINTS_PROXY_PORT:-18550}:${BOLT_SIDECAR_CONSTRAINTS_PROXY_PORT:-18550}"
entrypoint: /usr/local/bin/entrypoint.sh
volumes:
# Load the entrypoint script: an hook before starting the sidecar binary
# that overrides some of envs inside .env to match the volumes paths.
- ./entrypoint.sh:/usr/local/bin/entrypoint.sh
# Load the environment variables that will be sourced by the sidecar process.
- ./bolt-sidecar.env:/usr/local/bin/.env
# NOTE: to read these envs, it is necessary to provide them via `--env-file` or having them already set.
# This is a workaround because it is not possible to conditionally mount
# volumes. As such, if an env is not provided, we will mount `/dev/null`
# instead.
- ${BOLT_SIDECAR_DELEGATIONS_PATH:-/dev/null}:/etc/delegations.json
- ${BOLT_SIDECAR_KEYSTORE_PATH:-/dev/null}:/etc/keystores
- ${BOLT_SIDECAR_KEYSTORE_SECRETS_PATH:-/dev/null}:/etc/secrets
Expand Down
13 changes: 10 additions & 3 deletions testnets/holesky/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
# Exit immediately if a command exits with a non-zero status.
set -e

# Override the environment variables provided by the user.
# Make sure we're in the correct directory
cd /usr/local/bin

# Load the environment variables from the .env file.
source .env

# Override some of the environment variables provided by the user, even if
# provided via .env file, so that the volume mounts work as expected.
#
# The "+" syntax replaces the environment variable with the alternate valuee
# only if set.
# Reference: https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#interpolation-syntax

#
# Ensure these environment variables are either empty or set with the
# alternative values, overriding what's provided with the `--env-file` flag in
# the Docker Compose file and matching the volume mounts.
export BOLT_SIDECAR_DELEGATIONS_PATH="${BOLT_SIDECAR_DELEGATIONS_PATH+/etc/delegations.json}"
export BOLT_SIDECAR_KEYSTORE_PATH="${BOLT_SIDECAR_KEYSTORE_PATH+/etc/keystore}"
export BOLT_SIDECAR_KEYSTORE_SECRETS_PATH="${BOLT_SIDECAR_KEYSTORE_SECRETS_PATH+/etc/secrets}"

/usr/local/bin/bolt-sidecar
./bolt-sidecar
Loading