Skip to content

Commit

Permalink
Merge pull request #1465 from dandi/fix-compose
Browse files Browse the repository at this point in the history
Assorted Docker Compose improvements
  • Loading branch information
jwodder committed Jul 23, 2024
2 parents c893aa0 + 76e7d14 commit c0b64d5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ jobs:
- name: Dump Docker Compose logs
if: failure() && startsWith(matrix.os, 'ubuntu')
run: |
docker-compose \
docker compose \
-f dandi/tests/data/dandiarchive-docker/docker-compose.yml \
logs --timestamps
- name: Shut down Docker Compose
if: startsWith(matrix.os, 'ubuntu')
run: |
docker-compose \
docker compose \
-f dandi/tests/data/dandiarchive-docker/docker-compose.yml \
down -v
Expand Down
17 changes: 8 additions & 9 deletions dandi/tests/data/dandiarchive-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ services:
DJANGO_DANDI_WEB_APP_URL: http://localhost:8085
DJANGO_DANDI_API_URL: http://localhost:8000
DJANGO_DANDI_JUPYTERHUB_URL: https://hub.dandiarchive.org
DJANGO_DANDI_DEV_EMAIL: test@example.com
DANDI_ALLOW_LOCALHOST_URLS: "1"
DJANGO_DANDI_DEV_EMAIL: "test@example.com"
DANDI_ALLOW_LOCALHOST_URLS: "1"
ports:
- "8000:8000"
- "127.0.0.1:8000:8000"

celery:
image: dandiarchive/dandiarchive-api
Expand Down Expand Up @@ -81,16 +80,16 @@ services:
DJANGO_DANDI_WEB_APP_URL: http://localhost:8085
DJANGO_DANDI_API_URL: http://localhost:8000
DJANGO_DANDI_JUPYTERHUB_URL: https://hub.dandiarchive.org
DANDI_ALLOW_LOCALHOST_URLS: "1"
DJANGO_DANDI_DEV_EMAIL: "test@example.com"
DANDI_ALLOW_LOCALHOST_URLS: "1"

minio:
image: minio/minio:RELEASE.2022-04-12T06-55-35Z
# When run with a TTY, minio prints credentials on startup
tty: true
command: ["server", "/data"]
ports:
- "9000:9000"
- "127.0.0.1:9000:9000"
environment:
MINIO_ACCESS_KEY: minioAccessKey
MINIO_SECRET_KEY: minioSecretKey
Expand All @@ -105,8 +104,8 @@ services:
POSTGRES_DB: django
POSTGRES_PASSWORD: postgres
image: postgres
ports:
- "5432:5432"
expose:
- "5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 7s
Expand All @@ -115,5 +114,5 @@ services:

rabbitmq:
image: rabbitmq:management
ports:
- "5672:5672"
expose:
- "5672"
31 changes: 24 additions & 7 deletions dandi/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,27 @@ def docker_compose_setup() -> Iterator[dict[str, str]]:
try:
if create:
if os.environ.get("DANDI_TESTS_PULL_DOCKER_COMPOSE", "1") not in ("", "0"):
run(["docker-compose", "pull"], cwd=str(LOCAL_DOCKER_DIR), check=True)
run(
["docker", "compose", "pull"], cwd=str(LOCAL_DOCKER_DIR), check=True
)
run(
["docker-compose", "run", "--rm", "django", "./manage.py", "migrate"],
[
"docker",
"compose",
"run",
"--rm",
"django",
"./manage.py",
"migrate",
],
cwd=str(LOCAL_DOCKER_DIR),
env=env,
check=True,
)
run(
[
"docker-compose",
"docker",
"compose",
"run",
"--rm",
"django",
Expand All @@ -417,7 +428,8 @@ def docker_compose_setup() -> Iterator[dict[str, str]]:
)
run(
[
"docker-compose",
"docker",
"compose",
"run",
"--rm",
"-e",
Expand All @@ -436,7 +448,8 @@ def docker_compose_setup() -> Iterator[dict[str, str]]:

r = check_output(
[
"docker-compose",
"docker",
"compose",
"run",
"--rm",
"-T",
Expand All @@ -458,7 +471,7 @@ def docker_compose_setup() -> Iterator[dict[str, str]]:

if create:
run(
["docker-compose", "up", "-d", "django", "celery"],
["docker", "compose", "up", "-d", "django", "celery"],
cwd=str(LOCAL_DOCKER_DIR),
env=env,
check=True,
Expand All @@ -476,7 +489,11 @@ def docker_compose_setup() -> Iterator[dict[str, str]]:
yield {"django_api_key": django_api_key}
finally:
if persist in (None, "0"):
run(["docker-compose", "down", "-v"], cwd=str(LOCAL_DOCKER_DIR), check=True)
run(
["docker", "compose", "down", "-v"],
cwd=str(LOCAL_DOCKER_DIR),
check=True,
)


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion dandi/tests/skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def windows():

def no_docker_commands():
missing_cmds = []
for cmd in ("docker", "docker-compose"):
for cmd in ("docker",):
if shutil.which(cmd) is None:
missing_cmds.append(cmd)
msg = "missing Docker commands: {}".format(", ".join(missing_cmds))
Expand Down

0 comments on commit c0b64d5

Please sign in to comment.