Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
Switch everything to docker compose v2
Browse files Browse the repository at this point in the history
This switches all calls to docker-compose v1 to docker compose v2. This
lets us consolidate on one version of docker compose (the current one!)
  • Loading branch information
Thomas Wunderlich committed May 20, 2022
1 parent 9a5394b commit 3560f2a
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ any information you think might be useful for replicating it.

```

#### The output of `docker-compose --version`
#### The output of `docker compose --version`

```bash

Expand Down
8 changes: 4 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ The `build-test-unit` target is a [Dockerfile](./src/rust/Dockerfile) stage
that will builds dependencies for `cargo test` that wasn't done so in the
initial source build, `cargo build`.

We're currently using `docker-compose up` to run our tests concurrently. We
We're currently using `docker compose up` to run our tests concurrently. We
have a [helper script](./test/docker-compose-with-error.sh) that checks the
exit code for each container (test) run. If any test exit code is non-zero, the
script will return non-zero as well. This allows us to surface non-zero exit
Expand All @@ -202,7 +202,7 @@ the Grapl environment locally.
If you'd like to skip building and run the Grapl environment locally you can run:

``` bash
TAG=latest docker-compose up
TAG=latest docker compose up
```

Note that `TAG` should be set to whatever you used in your `make`
Expand All @@ -215,14 +215,14 @@ up-to-date with the latest `main` branch on GitHub for development and
testing. Example:

``` bash
TAG=main docker-compose up
TAG=main docker compose up
```

## Nomad
Grapl is transitioning to Nomad as our container orchestration. This will replace both AWS Fargate and docker-compose.

### Nomad local development setup
Have docker and docker-compose installed. Install Nomad and Consult following the instructions at
Have docker and docker compose installed. Install Nomad and Consult following the instructions at
https://www.nomadproject.io/downloads and https://www.consul.io/downloads respectively.

Install CNI plugins:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Grapl is organized as a monorepo with the following structure:

We use [GNU Make](https://www.gnu.org/software/make/),
[Docker](https://docs.docker.com/) (version 20.10 or later) and
[docker-compose](https://docs.docker.com/compose/) for local development. To
[docker compose](https://docs.docker.com/compose/) for local development. To
execute a Grapl debug build, execute the following command in the project root:

``` bash
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ COMPOSE_PROJECT_E2E_TESTS := grapl-e2e_tests
# While we would ultimately like to run all these containers as a
# non-root user, some currently seem to require that; to accommodate
# all such images, we provide two helpful macros.
DOCKER_COMPOSE_CHECK := docker-compose --file=docker-compose.check.yml run --rm
DOCKER_COMPOSE_CHECK := docker compose --file=docker-compose.check.yml run --rm
NONROOT_DOCKER_COMPOSE_CHECK := ${DOCKER_COMPOSE_CHECK} --user=${COMPOSE_USER}

# Our images are labeled; we can use this to help filter various
Expand Down Expand Up @@ -478,29 +478,29 @@ _up:
# explicitly unset that here to avoid potential surprises.
unset COMPOSE_FILE

# TODO: This could potentially be replaced with a docker-compose run, but
# TODO: This could potentially be replaced with a docker compose run, but
# it doesn't have all these useful flags
@echo "--- Running Pulumi"
docker-compose \
docker compose \
--file docker-compose.yml \
up --force-recreate --always-recreate-deps --renew-anon-volumes \
--exit-code-from pulumi \
pulumi

.PHONY: down
down: ## docker-compose down - both stops and removes the containers
down: ## docker compose down - both stops and removes the containers
# This is only for killing the lambda containers that Localstack
# spins up in our network, but that docker-compose doesn't know
# spins up in our network, but that docker compose doesn't know
# about. This must be the network that is used in Localstack's
# LAMBDA_DOCKER_NETWORK environment variable.
$(MAKE) stop-nomad-detach
docker-compose $(EVERY_COMPOSE_FILE) down --timeout=0
@docker-compose $(EVERY_COMPOSE_FILE) --project-name $(COMPOSE_PROJECT_INTEGRATION_TESTS) down --timeout=0
@docker-compose $(EVERY_COMPOSE_FILE) --project-name $(COMPOSE_PROJECT_E2E_TESTS) down --timeout=0
docker compose $(EVERY_COMPOSE_FILE) down --timeout=0
@docker compose $(EVERY_COMPOSE_FILE) --project-name $(COMPOSE_PROJECT_INTEGRATION_TESTS) down --timeout=0
@docker compose $(EVERY_COMPOSE_FILE) --project-name $(COMPOSE_PROJECT_E2E_TESTS) down --timeout=0

.PHONY: stop
stop: ## docker-compose stop - stops (but preserves) the containers
docker-compose $(EVERY_COMPOSE_FILE) stop
stop: ## docker compose stop - stops (but preserves) the containers
docker compose $(EVERY_COMPOSE_FILE) stop

# This is a convenience target for our frontend engineers, to make the dev loop
# slightly less arduous for grapl-web-ui/engagement-view development.
Expand Down Expand Up @@ -606,8 +606,8 @@ clean-all-rust:

.PHONY: local-pulumi
local-pulumi: export COMPOSE_PROJECT_NAME="grapl"
local-pulumi: ## launch pulumi via docker-compose up
docker-compose -f docker-compose.yml run pulumi
local-pulumi: ## launch pulumi via docker compose up
docker compose -f docker-compose.yml run pulumi

.PHONY: start-nomad-detach
start-nomad-detach: ## Start the Nomad environment, detached
Expand Down
2 changes: 1 addition & 1 deletion docs/development/integration_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the database from your Github test run!

.. image:: where_to_find_artifacts_on_github.png

- Then, go to ``$GRAPLROOT`` and ``docker-compose up``.
- Then, go to ``$GRAPLROOT`` and ``docker compose up``.

- Unzip the artifacts and navigate to the folder that looks something like ``grapl-data-dgraph/dgraph.r4730.u1103.0108``

Expand Down
8 changes: 0 additions & 8 deletions etc/chromeos/lib/installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ install_docker() {
sudo usermod -a -G docker "$USER"
fi

echo_banner "Install docker-compose (v1, old, Python)"
sudo curl --proto "=https" \
--tlsv1.2 \
--location \
--output /usr/local/bin/docker-compose \
"https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname --kernel-name)-$(uname --machine)"
sudo chmod +x /usr/local/bin/docker-compose

echo_banner "Install docker compose (v2, new, Go) CLI plugin"
user_docker_cli_plugins_dir="${HOME}/.docker/cli-plugins"
mkdir --parents "${user_docker_cli_plugins_dir}"
Expand Down
4 changes: 2 additions & 2 deletions etc/ci_scripts/dump_artifacts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
class Args:
def __init__(self) -> None:
parser = argparse.ArgumentParser(
description="Dump all Docker logs for a given docker-compose project"
description="Dump all Docker logs for a given docker compose project"
)
parser.add_argument(
"--compose-project",
dest="compose_project",
required=False,
default=None,
help="Docker Compose project. Do not specify if Docker-Compose is not involved (e.g. running against prod)",
help="Docker Compose project. Do not specify if Docker Compose is not involved (e.g. running against prod)",
)
parser.add_argument(
"--dump-agent-logs",
Expand Down
2 changes: 1 addition & 1 deletion etc/ci_scripts/dump_artifacts/docker_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def dump_volume(
compose_project: Optional[str], volume_name: str, artifacts_dir: Path
) -> None:
# Make a temporary container with the volume mounted
# docker-compose prefixes volume names with the compose project name.
# docker compose prefixes volume names with the compose project name.
prefix = f"{compose_project}_" if compose_project else ""
container_id = subprocess.run(
f"docker run -d --volume {prefix}{volume_name}:/{volume_name} alpine true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def _after_tests() -> None:
"""
Add any "after tests are executed, but before docker-compose down" stuff here.
Add any "after tests are executed, but before docker compose down" stuff here.
"""
# Issue a command to dgraph to export the whole database.
# This is then stored on a volume, `grapl-data-dgraph`.
Expand Down
8 changes: 4 additions & 4 deletions test/docker-compose-with-error.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ set -eu
usage() {
echo "Usage: [TARGETS=\"service1 service2\"] $0" 1>&2
echo
echo "This script calls into $(docker-compose up) and checks the exit code" 1>&2
echo "This script calls into $(docker compose up) and checks the exit code" 1>&2
echo "of each container upon exit. If any container exit code is non-zero," 1>&2
echo "this script will exit non-zero." 1>&2
echo
echo "Use Compose environment variables, such as COMPOSE_FILE and COMPOSE_PROJECT_NAME," 1>&2
echo "for directing docker-compose." 1>&2
echo "for directing docker compose." 1>&2
exit 1
}

# Execute the 'up'
docker-compose up \
docker compose up \
--force-recreate \
--always-recreate-deps \
--renew-anon-volumes \
${TARGETS}

# check for container exit codes other than 0
EXIT_CODE=0
ALL_TESTS=$(docker-compose ps --quiet ${TARGETS})
ALL_TESTS=$(docker compose ps --quiet ${TARGETS})
for test in $ALL_TESTS; do
test_exit_code=$(docker inspect -f "{{ .State.ExitCode }}" "${test}")
if [[ ${test_exit_code} -ne 0 ]]; then
Expand Down

0 comments on commit 3560f2a

Please sign in to comment.