From fc6a0e7a3238d78de533c195cd748a44f69d1704 Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Thu, 8 Aug 2024 07:55:09 -0500 Subject: [PATCH] Update test to use `docker compose`. --- readme.md | 6 +++--- util/common/__init__.py | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index 1009735be..9a554d9af 100644 --- a/readme.md +++ b/readme.md @@ -24,7 +24,7 @@ cd rDrama 4 - Run the following command to start the site: ```sh -docker-compose up --build +docker compose up --build ``` The first time you do this, it will take a while. It'll be (much) faster next time. @@ -35,7 +35,7 @@ The first time you do this, it will take a while. It'll be (much) faster next ti 6 - That's it! -Most code edits will be reflected (almost) immediately. If you make any setup changes or database changes, you'll need to ctrl-C the docker-compose status log and run `docker-compose up --build` again. +Most code edits will be reflected (almost) immediately. If you make any setup changes or database changes, you'll need to ctrl-C the docker status log and run `docker compose up --build` again. Chat-related code edits will take a minute to update (if it's in Python) or won't be reflected automatically at all (if it's in React). Improvements welcome! But almost nobody touches these systems, so it hasn't been a priority. @@ -99,7 +99,7 @@ def downgrade(): 4. Restart the Docker container to make sure it works. ```sh -docker-compose up --build +docker compose up --build ``` ## So what's up with original-schema.sql, can I just change that? diff --git a/util/common/__init__.py b/util/common/__init__.py index d240bcb64..38079bf79 100644 --- a/util/common/__init__.py +++ b/util/common/__init__.py @@ -54,7 +54,8 @@ def _execute(command,**kwargs): def _docker(command, **kwargs): return _execute([ - "docker-compose", + "docker", + "compose", "exec", '-T', "site", ] + command, @@ -64,7 +65,8 @@ def _start(): print("Starting containers in operation mode . . .") print(" If this takes a while, it's probably building the container.") command = [ - 'docker-compose', + 'docker', + 'compose', '-f', 'docker-compose.yml', '-f', 'docker-compose-operation.yml', 'up', @@ -83,16 +85,16 @@ def _start(): # previous versions of this code also had a check to see if the containers started up properly # but this is surprisingly annoying to do if we don't know the containers' names - # docker-compose *can* do it, but you either have to use very new features that aren't supported on Ubuntu 22.04, or you have to go through a bunch of parsing pain + # docker compose *can* do it, but you either have to use very new features that aren't supported on Ubuntu 22.04, or you have to go through a bunch of parsing pain # and it kind of doesn't seem necessary - # see, docker-compose in this form *will* wait until it's *attempted* to start each container. + # see, docker compose in this form *will* wait until it's *attempted* to start each container. # so at this point in execution, either the containers are running, or they're crashed # if they're running, hey, problem solved, we're good # if they're crashed, y'know what, problem still solved! because our next command will fail # maybe there's still a race condition? I dunno! Keep an eye on this. - # If there is a race condition then you're stuck doing something gnarly with `docker-compose ps`. Good luck! + # If there is a race condition then you're stuck doing something gnarly with `docker compose ps`. Good luck! print(" Containers started!") @@ -100,7 +102,7 @@ def _start(): def _stop(): # use "stop" instead of "down" to avoid killing all stored data - command = ['docker-compose','stop'] + command = ['docker', 'compose', 'stop'] print("Stopping containers . . .") result = _execute(command) return result