Skip to content

Commit

Permalink
check Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
norswap committed Dec 8, 2023
1 parent b346a32 commit 20cdf17
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The following dependencies will be checked by `roll.py`:

- Some common command line utilities: `make`, `curl`, `tar`, `awk` and `grep`.
- Git
- Docker (if you wish to run the Blockscout block explorer)

`roll.py` will check the following dependencies and install them for you if needed (the script will
always for your permission before installing anything outside the current directory):
Expand Down
1 change: 1 addition & 0 deletions block_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def launch_blockscout(config: Config):
"""
Launch the blockscout block explorer, setting up the repo if necessary.
"""
deps.check_docker()
setup_blockscout_repo()

log_file_name = "logs/launch_blockscout.log"
Expand Down
32 changes: 32 additions & 0 deletions deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,36 @@ def install_geth():

print(f"Successfully installed geth {INSTALL_GETH_VERSION} as ./bin/geth")


####################################################################################################

MIN_DOCKER_VERSION = "24"
"""
Minimum supported Docker version. This is somewhat arbitrary, simply the latest major version,
that we also tested with.
"""


def check_docker():
if shutil.which("docker") is None:
raise Exception(
"Docker is not installed. Please install either Docker Engine or Docker Desktop\n"
"by following the instructions at https://docs.docker.com/engine/install/.")

version_blob = lib.run("get docker version", "docker --version")
match = re.search(r"(\d+\.\d+\.\d+)", version_blob)
if match is None:
raise Exception("Failed to parse the Docker version, "
f"try updating Docker engine to v{MIN_DOCKER_VERSION} or higher.")
elif match.group(1) < MIN_DOCKER_VERSION:
raise Exception(f"Please update docker to {MIN_DOCKER_VERSION} or higher. "
"Refer to https://docs.docker.com/engine/install/")

try:
lib.run("try running docker compose", "docker compose version")
except Exception:
raise Exception("Docker Compose not available, please install the Compose plugin. "
"Refer to https://docs.docker.com/compose/install/")


####################################################################################################

0 comments on commit 20cdf17

Please sign in to comment.