From 1c6f7855fe1624152667ad93318deef059300dd5 Mon Sep 17 00:00:00 2001 From: Amanda Lim-Cabuloy Date: Wed, 8 Jan 2025 16:19:45 +0800 Subject: [PATCH] Revert "Merge branch 'chore/docker-compose_to_docker_compose' into staging" This reverts commit d3d2dd879df91fa4a86adf21e36ff31272083716, reversing changes made to 4e215d8aa70435ece94abff4f3aec4a7bb0ca4e3. --- Dockerfile | 8 ++++---- docker-compose.yml | 1 + docker/docker-compose-frontend.yml | 1 + fabfile.py | 29 ++++++++++++----------------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2fc59b0f1..116207757 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20 AS frontend +FROM node:20 as frontend # Make build & post-install scripts behave as if we were in a CI environment (e.g. for logging verbosity purposes). ARG CI=true @@ -91,10 +91,10 @@ COPY ./docker/bashrc.sh /home/tbx/.bashrc # Run the WSGI server. It reads GUNICORN_CMD_ARGS, PORT and WEB_CONCURRENCY # environment variable hence we don't specify a lot options below. -CMD ["gunicorn", "tbx.wsgi:application"] +CMD gunicorn tbx.wsgi:application # These steps won't be run on production -FROM production AS dev +FROM production as dev # Swap user, so the following tasks can be run as root USER root @@ -117,4 +117,4 @@ RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh COPY --chown=tbx --from=frontend ./node_modules ./node_modules # do nothing forever - exec commands elsewhere -CMD ["tail", "-f", "/dev/null"] +CMD tail -f /dev/null diff --git a/docker-compose.yml b/docker-compose.yml index 689a48329..5fa48c3e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +version: '3.7' services: web: build: diff --git a/docker/docker-compose-frontend.yml b/docker/docker-compose-frontend.yml index 16203e15f..bf97554d9 100644 --- a/docker/docker-compose-frontend.yml +++ b/docker/docker-compose-frontend.yml @@ -1,5 +1,6 @@ # A custom compose file for $FRONTEND=docker, which also binds frontend ports +version: '3.7' # NB synchronise with /docker-compose.yml services: web: ports: diff --git a/fabfile.py b/fabfile.py index f2ac16def..d048f0906 100644 --- a/fabfile.py +++ b/fabfile.py @@ -36,7 +36,7 @@ def dexec(cmd, service="web"): - return local(f"docker compose exec -T {quote(service)} bash -c {quote(cmd)}") + return local(f"docker-compose exec -T {quote(service)} bash -c {quote(cmd)}") @task @@ -52,8 +52,8 @@ def build(c): local(f"chown -R $USER:{group} {directories_arg}") local("chmod -R 775 " + directories_arg) - local("docker compose pull", pty=True) - local("docker compose build", pty=True) + local("docker-compose pull") + local("docker-compose build") @task @@ -62,11 +62,10 @@ def start(c): Start the development environment """ if FRONTEND == "local": - local("docker compose up --detach", pty=True) + local("docker-compose up -d") else: local( - "docker compose -f docker-compose.yml -f docker/docker-compose-frontend.yml up -d", - pty=True, + "docker-compose -f docker-compose.yml -f docker/docker-compose-frontend.yml up -d" ) @@ -75,7 +74,7 @@ def stop(c): """ Stop the development environment """ - local("docker compose stop", pty=True) + local("docker-compose stop") @task @@ -92,7 +91,7 @@ def destroy(c): """ Destroy development environment containers (database will lost!) """ - local("docker compose down --volumes", pty=True) + local("docker-compose down") @task @@ -100,7 +99,7 @@ def sh(c, service="web"): """ Run bash in a local container """ - subprocess.run(["docker", "compose", "exec", service, "bash"]) + subprocess.run(["docker-compose", "exec", service, "bash"]) @task @@ -108,7 +107,7 @@ def sh_root(c, service="web"): """ Run bash as root in the local web container. """ - subprocess.run(["docker", "compose", "exec", "--user=root", "web", "bash"]) + subprocess.run(["docker-compose", "exec", "--user=root", "web", "bash"]) @task @@ -117,8 +116,7 @@ def psql(c, command=None): Connect to the local postgres DB using psql """ cmd_list = [ - "docker", - "compose", + "docker-compose", "exec", "db", "psql", @@ -454,8 +452,7 @@ def run_test(c): """ subprocess.call( [ - "docker", - "compose", + "docker-compose", "exec", "web", "python", @@ -472,6 +469,4 @@ def migrate(c): """ Run database migrations """ - subprocess.run( - ["docker", "compose", "run", "--rm", "web", "./manage.py", "migrate"] - ) + subprocess.run(["docker-compose", "run", "--rm", "web", "./manage.py", "migrate"])