diff --git a/Dockerfile b/Dockerfile index b087cb8ea..dcde7b0a3 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 @@ -16,7 +16,7 @@ RUN npm run build:prod # ones becase they use a different C compiler. Debian images also come with # all useful packages required for image manipulation out of the box. They # however weight a lot, approx. up to 1.5GiB per built image. -FROM python:3.11 as production +FROM python:3.11 AS production ARG POETRY_INSTALL_ARGS="--no-dev" @@ -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 5fa48c3e8..689a48329 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.7' services: web: build: diff --git a/docker/docker-compose-frontend.yml b/docker/docker-compose-frontend.yml index bf97554d9..16203e15f 100644 --- a/docker/docker-compose-frontend.yml +++ b/docker/docker-compose-frontend.yml @@ -1,6 +1,5 @@ # 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 11ec2e8b1..ce8d4e29f 100644 --- a/fabfile.py +++ b/fabfile.py @@ -37,7 +37,7 @@ def dexec(cmd, service="web"): return local( - "docker-compose exec -T {} bash -c {}".format(quote(service), quote(cmd)) + "docker compose exec -T {} bash -c {}".format(quote(service), quote(cmd)) ) @@ -54,8 +54,8 @@ def build(c): local("chown -R $USER:{} {}".format(group, directories_arg)) local("chmod -R 775 " + directories_arg) - local("docker-compose pull") - local("docker-compose build") + local("docker compose pull", pty=True) + local("docker compose build", pty=True) @task @@ -64,10 +64,11 @@ def start(c): Start the development environment """ if FRONTEND == "local": - local("docker-compose up -d") + local("docker compose up --detach", pty=True) else: local( - "docker-compose -f docker-compose.yml -f docker/docker-compose-frontend.yml up -d" + "docker compose -f docker-compose.yml -f docker/docker-compose-frontend.yml up -d", + pty=True, ) @@ -76,7 +77,7 @@ def stop(c): """ Stop the development environment """ - local("docker-compose stop") + local("docker compose stop", pty=True) @task @@ -93,7 +94,7 @@ def destroy(c): """ Destroy development environment containers (database will lost!) """ - local("docker-compose down") + local("docker compose down --volumes", pty=True) @task @@ -101,7 +102,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 @@ -109,7 +110,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 @@ -118,7 +119,8 @@ def psql(c, command=None): Connect to the local postgres DB using psql """ cmd_list = [ - "docker-compose", + "docker", + "compose", "exec", "db", "psql", @@ -458,7 +460,8 @@ def run_test(c): """ subprocess.call( [ - "docker-compose", + "docker", + "compose", "exec", "web", "python", @@ -475,4 +478,6 @@ 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"] + )