Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
feat(zk_toolbox): Use docker compose instead of docker-compose (matte…
Browse files Browse the repository at this point in the history
…r-labs#2195)

## What ❔

Use `docker compose` instead of `docker-compose`

## Why ❔

The recommended command-line syntax is docker compose:

https://docs.docker.com/compose/migrate/#docker-compose-vs-docker-compose
  • Loading branch information
matias-gonz authored and gabrieldemian committed Jun 21, 2024
1 parent ffc1887 commit f900fb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions zk_toolbox/crates/common/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use xshell::{cmd, Shell};
use crate::cmd::Cmd;

pub fn up(shell: &Shell, docker_compose_file: &str) -> anyhow::Result<()> {
Cmd::new(cmd!(shell, "docker-compose -f {docker_compose_file} up -d")).run()
Cmd::new(cmd!(shell, "docker compose -f {docker_compose_file} up -d")).run()
}
pub fn down(shell: &Shell, docker_compose_file: &str) -> anyhow::Result<()> {
Cmd::new(cmd!(shell, "docker-compose -f {docker_compose_file} down")).run()
Cmd::new(cmd!(shell, "docker compose -f {docker_compose_file} down")).run()
}
21 changes: 16 additions & 5 deletions zk_toolbox/crates/common/src/prerequisites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use xshell::{cmd, Shell};

use crate::{cmd::Cmd, logger};

const PREREQUISITES: [Prerequisite; 6] = [
const PREREQUISITES: [Prerequisite; 5] = [
Prerequisite {
name: "git",
download_link: "https://git-scm.com/book/en/v2/Getting-Started-Installing-Git",
Expand All @@ -11,10 +11,6 @@ const PREREQUISITES: [Prerequisite; 6] = [
name: "docker",
download_link: "https://docs.docker.com/get-docker/",
},
Prerequisite {
name: "docker-compose",
download_link: "https://docs.docker.com/compose/install/",
},
Prerequisite {
name: "forge",
download_link: "https://book.getfoundry.sh/getting-started/installation",
Expand All @@ -29,6 +25,11 @@ const PREREQUISITES: [Prerequisite; 6] = [
},
];

const DOCKER_COMPOSE_PREREQUISITE: Prerequisite = Prerequisite {
name: "docker compose",
download_link: "https://docs.docker.com/compose/install/",
};

struct Prerequisite {
name: &'static str,
download_link: &'static str,
Expand All @@ -43,6 +44,10 @@ pub fn check_prerequisites(shell: &Shell) {
}
}

if !check_docker_compose_prerequisite(shell) {
missing_prerequisites.push(&DOCKER_COMPOSE_PREREQUISITE);
}

if !missing_prerequisites.is_empty() {
logger::error("Prerequisite check has failed");
logger::error_note(
Expand All @@ -63,3 +68,9 @@ pub fn check_prerequisites(shell: &Shell) {
fn check_prerequisite(shell: &Shell, name: &str) -> bool {
Cmd::new(cmd!(shell, "which {name}")).run().is_ok()
}

fn check_docker_compose_prerequisite(shell: &Shell) -> bool {
Cmd::new(cmd!(shell, "docker compose version"))
.run()
.is_ok()
}

0 comments on commit f900fb6

Please sign in to comment.