From 8584d4ba5d4ca6e9c908d2784360c5951a505a48 Mon Sep 17 00:00:00 2001 From: BeritJanssen Date: Fri, 27 Sep 2024 14:22:40 +0200 Subject: [PATCH] fix: docker compose without hyphen --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/podman.yml | 32 ++++++++++++++++---------------- README.md | 10 +++++----- package.json | 4 ++-- scripts/build-front | 2 +- scripts/lint-back | 2 +- scripts/lint-front | 2 +- scripts/manage | 2 +- scripts/test-back | 2 +- scripts/test-back-coverage | 2 +- scripts/test-front | 2 +- scripts/test-front-ci | 2 +- scripts/test-front-watch | 2 +- 13 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05544648e..ef41a3067 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,16 +11,16 @@ jobs: steps: - uses: actions/checkout@v3 - name: Run Backend Tests - run: sudo docker-compose --env-file .env-github-actions run server bash -c "coverage run manage.py test" + run: sudo docker compose --env-file .env-github-actions run server bash -c "coverage run manage.py test" - name: Generate Backend Coverage Report (Inline) - run: sudo docker-compose --env-file .env-github-actions run server bash -c "coverage report --show-missing" + run: sudo docker compose --env-file .env-github-actions run server bash -c "coverage report --show-missing" # Generate coverage badge (only for main and develop branches) - name: Generate Backend Coverage Report (XML) and Badge if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' run: | - sudo docker-compose --env-file .env-github-actions run server bash -c "coverage xml" - sudo docker-compose --env-file .env-github-actions run server bash -c "genbadge coverage -i coverage.xml -o coverage-backend-badge-new.svg -n \"Backend Code Coverage\"" + sudo docker compose --env-file .env-github-actions run server bash -c "coverage xml" + sudo docker compose --env-file .env-github-actions run server bash -c "genbadge coverage -i coverage.xml -o coverage-backend-badge-new.svg -n \"Backend Code Coverage\"" # Push coverage badge to separate branch (only for main and develop branches) - name: Push Backend Coverage Badge to separate branch continue-on-error: true @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v3 - name: Lint Backend continue-on-error: false - run: sudo docker-compose --env-file .env-github-actions run server bash -c "flake8" + run: sudo docker compose --env-file .env-github-actions run server bash -c "flake8" frontend-test: name: Test Frontend @@ -63,7 +63,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Run Frontend Tests - run: sudo docker-compose --env-file .env-github-actions run client yarn test:ci + run: sudo docker compose --env-file .env-github-actions run client yarn test:ci frontend-coverage-badge: name: Generate Frontend Coverage Badge @@ -74,8 +74,8 @@ jobs: - uses: actions/checkout@v3 - name: Generate Frontend Coverage Report (XML) and Badge run: | - sudo docker-compose --env-file .env-github-actions run client yarn test:ci - sudo docker-compose --env-file .env-github-actions run client yarn coverage-badges -s public/coverage/coverage-summary.json -o public/coverage/coverage-frontend-badge-new.svg --label 'Frontend Code Coverage' + sudo docker compose --env-file .env-github-actions run client yarn test:ci + sudo docker compose --env-file .env-github-actions run client yarn coverage-badges -s public/coverage/coverage-summary.json -o public/coverage/coverage-frontend-badge-new.svg --label 'Frontend Code Coverage' - name: Push Frontend Coverage Badge to separate branch continue-on-error: true run: | @@ -106,4 +106,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - run: sudo docker-compose --env-file .env-github-actions run client yarn lint + - run: sudo docker compose --env-file .env-github-actions run client yarn lint diff --git a/.github/workflows/podman.yml b/.github/workflows/podman.yml index 6f0ee907b..14e73b2df 100644 --- a/.github/workflows/podman.yml +++ b/.github/workflows/podman.yml @@ -79,11 +79,11 @@ jobs: echo "VITE_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env cp .env frontend/.env - name: Build Podman images - run: podman-compose -f docker-compose-deploy.yml build + run: podman-compose -f docker compose-deploy.yml build - name: Shut down running containers - run: podman compose -f docker-compose-deploy.yml down + run: podman compose -f docker compose-deploy.yml down - name: Deploy Podman images - run: podman-compose -f docker-compose-deploy.yml up -d + run: podman-compose -f docker compose-deploy.yml up -d - name: Notify Sentry of new release run: | curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \ @@ -101,15 +101,15 @@ jobs: - name: Prune old images run: podman image prune -a -f - name: Check Podman images - run: podman-compose -f docker-compose-deploy.yml ps + run: podman-compose -f docker compose-deploy.yml ps - name: Check logs - run: podman-compose -f docker-compose-deploy.yml logs + run: podman-compose -f docker compose-deploy.yml logs deploy-acceptance: name: Deploy to acceptance environment environment: Acceptance runs-on: ACC - + # this job runs only on commits to the main branch, tags, or when manually triggered for the main branch if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') concurrency: @@ -171,11 +171,11 @@ jobs: echo "VITE_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env cp .env frontend/.env - name: Build Podman images - run: podman-compose -f docker-compose-deploy.yml build + run: podman-compose -f docker compose-deploy.yml build - name: Shut down running containers - run: podman compose -f docker-compose-deploy.yml down + run: podman compose -f docker compose-deploy.yml down - name: Deploy Podman images - run: podman-compose -f docker-compose-deploy.yml up -d + run: podman-compose -f docker compose-deploy.yml up -d - name: Notify Sentry of new release run: | curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \ @@ -193,9 +193,9 @@ jobs: - name: Prune old images run: podman image prune -a -f - name: Check Podman images - run: podman-compose -f docker-compose-deploy.yml ps + run: podman-compose -f docker compose-deploy.yml ps - name: Check logs - run: podman-compose -f docker-compose-deploy.yml logs + run: podman-compose -f docker compose-deploy.yml logs deploy-production: name: Deploy to production environment @@ -260,11 +260,11 @@ jobs: echo "VITE_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env cp .env frontend/.env - name: Build Podman images - run: podman-compose -f docker-compose-deploy.yml build + run: podman-compose -f docker compose-deploy.yml build - name: Shut down running containers - run: podman compose -f docker-compose-deploy.yml down + run: podman compose -f docker compose-deploy.yml down - name: Deploy Podman images - run: podman-compose -f docker-compose-deploy.yml up -d + run: podman-compose -f docker compose-deploy.yml up -d - name: Notify Sentry of new release run: | curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \ @@ -282,8 +282,8 @@ jobs: - name: Prune old images run: podman image prune -a -f - name: Check Podman images - run: podman-compose -f docker-compose-deploy.yml ps - + run: podman-compose -f docker compose-deploy.yml ps + e2e-acceptance: name: E2E tests on acceptance environment runs-on: ACC diff --git a/README.md b/README.md index 71989f196..63e9aaf4a 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ Install [Docker Desktop](https://docs.docker.com/desktop/). Make a copy of [the file](https://github.com/Amsterdam-Music-Lab/MUSCLE/blob/develop/.env.dist) `.env.dist` (in the same directory as this README) and rename it to `.env.` This file contains variables used by Docker to start up a container network serving MUSCLE. Start Docker (the app icon is a whale carrying containers). Then, open a terminal and run -`docker-compose up` (add `sudo` on Linux). -This command starts up the containers defined in `docker-compose.yaml`: +`docker compose up` (add `sudo` on Linux). +This command starts up the containers defined in `docker compose.yaml`: - a PostgreSQL container, for storing experiment/user/playlist data, saved on the host machine in the Docker user data, represented in the volume `db_data`. Data added to the database will persist if the container is shut down. - a ip2country container, which provides country codes for ip addresses, used for demographic information of users. - a container of the server, defined in DockerfileDevelop in `backend`. The Dockerfile defines the Python version and installs development dependencies. The startup command runs migrations and then starts up a Django development server. @@ -39,13 +39,13 @@ This command starts up the containers defined in `docker-compose.yaml`: Once you see all containers have started up, open your browser and navigate to [localhost:3000](http://localhost:3000). You should now be able to see the first screen of the Goldsmiths Musical Sophistication Index questionnaire. -Since the `docker-compose.yaml` defines bind mounts for `backend` and `frontend`, any changes to the files on the host are immediately reflected in the containers, which means code watching works and hot reload works in the same way as with a native node or Django server. +Since the `docker compose.yaml` defines bind mounts for `backend` and `frontend`, any changes to the files on the host are immediately reflected in the containers, which means code watching works and hot reload works in the same way as with a native node or Django server. To stop the containers, press `ctrl-c` or (in another terminal) run -`docker-compose down`. +`docker compose down`. ## Production build -A production build should define its own `docker-compose.yaml`, making use of the `Dockerfile` of the `backend` and `frontend` environments. It should also define a custom .env file, with safe passwords for the SQL database and the Python backend. Instead of mounting the entire backend and frontend directory and using the development servers, the backend should serve with gunicorn, and the frontend should use a build script to compile static html, css and JavaScript. +A production build should define its own `docker compose.yaml`, making use of the `Dockerfile` of the `backend` and `frontend` environments. It should also define a custom .env file, with safe passwords for the SQL database and the Python backend. Instead of mounting the entire backend and frontend directory and using the development servers, the backend should serve with gunicorn, and the frontend should use a build script to compile static html, css and JavaScript. ## Troubleshooting diff --git a/package.json b/package.json index fe200f419..c235ed5ae 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "description": "The MUSCLE platform is an application that provides an easy way to implement and run online listening experiments for music research.", "license": "MIT", "scripts": { - "test-front": "sudo docker-compose run client yarn test --watchAll=false", - "test-back": "sudo docker-compose run server bash -c 'python manage.py test'" + "test-front": "sudo docker compose run client yarn test --watchAll=false", + "test-back": "sudo docker compose run server bash -c 'python manage.py test'" }, "packageManager": "yarn@4.1.1" } diff --git a/scripts/build-front b/scripts/build-front index 8b70ab8fb..fa7d48725 100755 --- a/scripts/build-front +++ b/scripts/build-front @@ -1,3 +1,3 @@ #!/bin/bash -docker-compose run --rm client yarn build +docker compose run --rm client yarn build diff --git a/scripts/lint-back b/scripts/lint-back index 533b74a94..c83b8fbc1 100755 --- a/scripts/lint-back +++ b/scripts/lint-back @@ -1,2 +1,2 @@ #!/bin/bash -docker-compose run --rm server bash -c "flake8" +docker compose run --rm server bash -c "flake8" diff --git a/scripts/lint-front b/scripts/lint-front index ad826e4f8..2e313c2f5 100755 --- a/scripts/lint-front +++ b/scripts/lint-front @@ -1,2 +1,2 @@ #!/bin/bash -docker-compose run --rm client yarn lint $@ +docker compose run --rm client yarn lint $@ diff --git a/scripts/manage b/scripts/manage index 8c7cccdc5..9e3ca3918 100755 --- a/scripts/manage +++ b/scripts/manage @@ -1,4 +1,4 @@ #!/bin/bash # This script executes Django management commands through Docker. -docker-compose run --rm server python manage.py $@ \ No newline at end of file +docker compose run --rm server python manage.py $@ diff --git a/scripts/test-back b/scripts/test-back index 8d367adff..e85bcb44b 100755 --- a/scripts/test-back +++ b/scripts/test-back @@ -1,3 +1,3 @@ #!/bin/bash -docker-compose run --rm server bash -c "python manage.py test $@" +docker compose run --rm server bash -c "python manage.py test $@" diff --git a/scripts/test-back-coverage b/scripts/test-back-coverage index 67a0101e0..344636b72 100755 --- a/scripts/test-back-coverage +++ b/scripts/test-back-coverage @@ -1,3 +1,3 @@ #!/bin/bash -docker-compose run --rm server bash -c "coverage run manage.py test && coverage report --show-missing" +docker compose run --rm server bash -c "coverage run manage.py test && coverage report --show-missing" diff --git a/scripts/test-front b/scripts/test-front index a2fd3536d..3815ce120 100755 --- a/scripts/test-front +++ b/scripts/test-front @@ -1,3 +1,3 @@ #!/bin/bash -docker-compose run --rm client yarn test --watch=false +docker compose run --rm client yarn test --watch=false diff --git a/scripts/test-front-ci b/scripts/test-front-ci index d630b82c9..14a83b113 100755 --- a/scripts/test-front-ci +++ b/scripts/test-front-ci @@ -1,2 +1,2 @@ #!/bin/bash -docker-compose run --rm client yarn test:ci +docker compose run --rm client yarn test:ci diff --git a/scripts/test-front-watch b/scripts/test-front-watch index bb76f6de1..2600ef7c9 100755 --- a/scripts/test-front-watch +++ b/scripts/test-front-watch @@ -1,3 +1,3 @@ #!/bin/bash -docker-compose run --rm client yarn test --watch=true +docker compose run --rm client yarn test --watch=true