Skip to content

Commit

Permalink
Migrate to Compose v2
Browse files Browse the repository at this point in the history
Remove duplicated networks entry in flower container definition

Remove docker-comopose from dependencies and bump others

Remove "version:" from compose files
  • Loading branch information
snglth committed Sep 13, 2024
1 parent 9b1ed0b commit f0516e2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 101 deletions.
1 change: 0 additions & 1 deletion derex/runner/compose_files/docker-compose-admin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Services to monitor/inspect Open edX
version: "3.5"
services:
adminer:
image: adminer:4.7.6
Expand Down
1 change: 0 additions & 1 deletion derex/runner/compose_files/docker-compose-services.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Services needed for Open edX to work
version: "3.5"
services:
mongodb:
image: mongo:3.2.21
Expand Down
29 changes: 14 additions & 15 deletions derex/runner/compose_utils.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
from compose.cli.main import main
from contextlib import contextmanager
from typing import List

import click
import derex # noqa # This is ugly, but makes mypy and flake8 happy and still performs type checks
import logging
import subprocess
import sys


logger = logging.getLogger(__name__)


def run_compose(compose_argv: List[str]):
subprocess.run(["docker", "compose"] + compose_argv)


def run_docker_compose(
compose_argv: List[str], dry_run: bool = False, exit_afterwards: bool = False
):
"""Run a docker-compose command with the specified arguments."""
system_argv = sys.argv
try:
sys.argv = ["docker-compose"] + compose_argv
if not dry_run:
click.echo(f'Running\n{" ".join(sys.argv)}', err=True)
if exit_afterwards:
main()
else:
with exit_cm():
main()
if not dry_run:
click.echo(f'Running\ndocker compose {" ".join(compose_argv)}', err=True)
if exit_afterwards:
run_compose(compose_argv)
else:
click.echo("Would have run:\n")
click.echo(click.style(" ".join(sys.argv), fg="blue"))
finally:
sys.argv = system_argv
with exit_cm():
run_compose(compose_argv)
else:
click.echo("Would have run:\n")
click.echo(click.style(" ".join(sys.argv), fg="blue"))


@contextmanager
Expand Down
4 changes: 0 additions & 4 deletions derex/runner/templates/docker-compose-project.yml.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Open edX services
version: "3.5"

x-common:
&common-conf
{% if project.runmode.name == "production" -%}
Expand Down Expand Up @@ -70,8 +68,6 @@ services:
<<: *common-env
SERVICE_VARIANT: lms
container_name: {{ project.name }}_flower
networks:
- derex
networks:
derex:
aliases:
Expand Down
2 changes: 0 additions & 2 deletions derex/runner/templates/docker-compose-test.yml.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Test Open edX services
version: "3.5"

services:
cypress:
image: cypress/included:6.4.0
Expand Down
103 changes: 26 additions & 77 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile
#
annotated-types==0.6.0
annotated-types==0.7.0
# via pydantic
appdirs==1.4.4
# via derex.runner (setup.py)
attrs==23.1.0
# via jsonschema
bcrypt==4.0.1
# via paramiko
certifi==2023.7.22
certifi==2024.8.30
# via requests
cffi==1.16.0
# via
# cryptography
# pynacl
charset-normalizer==3.3.2
# via requests
click==8.1.7
Expand All @@ -27,96 +19,53 @@ click==8.1.7
# typer
click-plugins==1.1.1
# via derex.runner (setup.py)
cryptography==41.0.5
# via paramiko
distro==1.8.0
# via docker-compose
docker[ssh]==6.1.3
# via docker-compose
docker-compose==1.29.2
# via derex.runner (setup.py)
dockerpty==0.4.1
# via docker-compose
docopt==0.6.2
# via docker-compose
idna==3.4
idna==3.8
# via requests
importlib-metadata==6.8.0
importlib-metadata==8.5.0
# via derex.runner (setup.py)
jinja2==3.1.2
jinja2==3.1.4
# via derex.runner (setup.py)
jsonschema==3.2.0
# via docker-compose
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.3
markupsafe==2.1.5
# via jinja2
mdurl==0.1.2
# via markdown-it-py
packaging==23.2
# via docker
paramiko==3.3.1
# via docker
pluggy==1.3.0
pluggy==1.5.0
# via derex.runner (setup.py)
pycparser==2.21
# via cffi
pydantic==2.4.2
pydantic==2.9.1
# via python-on-whales
pydantic-core==2.10.1
pydantic-core==2.23.3
# via pydantic
pygments==2.16.1
pygments==2.18.0
# via rich
pymongo==3.13.0
# via derex.runner (setup.py)
pymysql==1.1.0
pymysql==1.1.1
# via derex.runner (setup.py)
pynacl==1.5.0
# via paramiko
pyrsistent==0.20.0
# via jsonschema
python-dotenv==0.21.1
# via docker-compose
python-on-whales==0.67.0
python-on-whales==0.73.0
# via derex.runner (setup.py)
pyyaml==5.3
# via
# derex.runner (setup.py)
# docker-compose
requests==2.31.0
# via
# docker
# docker-compose
# python-on-whales
rich==13.6.0
# via derex.runner (setup.py)
six==1.16.0
requests==2.32.3
# via python-on-whales
rich==13.8.1
# via
# dockerpty
# jsonschema
# websocket-client
texttable==1.7.0
# via docker-compose
tqdm==4.66.1
# derex.runner (setup.py)
# typer
shellingham==1.5.4
# via typer
tqdm==4.66.5
# via python-on-whales
typer==0.9.0
typer==0.12.5
# via python-on-whales
typing-extensions==4.8.0
typing-extensions==4.12.2
# via
# pydantic
# pydantic-core
# python-on-whales
# typer
urllib3==2.0.7
# via
# docker
# requests
websocket-client==0.59.0
# via
# docker
# docker-compose
zipp==3.17.0
urllib3==2.2.3
# via requests
zipp==3.20.2
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"appdirs",
"Click",
"click_plugins",
"docker-compose",
"importlib_metadata",
"jinja2",
"pluggy",
Expand Down

0 comments on commit f0516e2

Please sign in to comment.