Skip to content

Commit

Permalink
fix(docker compose): Use 'docker compose' everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Sep 16, 2024
1 parent cded3cf commit a5bfd5a
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A clear and concise description of what you expected to happen.
- DefectDojo version (see footer) or commit message: [use `git show -s --format="[%ci] %h: %s [%d]"`]

**Logs**
Use `docker-compose logs` (or similar, depending on your deployment method) to get the logs and add the relevant sections here showing the error occurring (if applicable).
Use `docker compose logs` (or similar, depending on your deployment method) to get the logs and add the relevant sections here showing the error occurring (if applicable).

**Sample scan files**
If applicable, add sample scan files to help reproduce your problem.
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/support_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A clear and concise description of what you expected to happen.
- DefectDojo version (see footer) or commit message: [use `git show -s --format="[%ci] %h: %s [%d]"`]

**Logs**
Use `docker-compose logs` (or similar, depending on your deployment method) to get the logs and add the relevant sections here showing the error occurring (if applicable).
Use `docker compose logs` (or similar, depending on your deployment method) to get the logs and add the relevant sections here showing the error occurring (if applicable).

**Sample scan files**
If applicable, add sample scan files to help reproduce your problem.
Expand Down
8 changes: 4 additions & 4 deletions dc-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ if [ $# -eq 0 ]
then
echo "Building docker compose"
# Compose V2 integrates compose functions into the Docker platform,
# continuing to support most of the previous docker-compose features
# continuing to support most of the previous docker compose features
# and flags. You can run Compose V2 by replacing the hyphen (-) with
# a space, using docker compose, instead of docker-compose.
# a space, using docker compose, instead of docker compose.
docker compose build
else
echo "Building docker compose with additional parameter $1 ..."
# Compose V2 integrates compose functions into the Docker platform,
# continuing to support most of the previous docker-compose features
# continuing to support most of the previous docker compose features
# and flags. You can run Compose V2 by replacing the hyphen (-) with
# a space, using docker compose, instead of docker-compose.
# a space, using docker compose, instead of docker compose.
docker compose build "$1"
fi
8 changes: 4 additions & 4 deletions dc-down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ if [ $# -eq 0 ]
then
echo "Stopping docker compose and removing containers"
# Compose V2 integrates compose functions into the Docker platform,
# continuing to support most of the previous docker-compose features
# continuing to support most of the previous docker compose features
# and flags. You can run Compose V2 by replacing the hyphen (-) with
# a space, using docker compose, instead of docker-compose.
# a space, using docker compose, instead of docker compose.
docker compose down
else
echo "Stopping docker compose and removing containers with additional parameter $1 ..."
# Compose V2 integrates compose functions into the Docker platform,
# continuing to support most of the previous docker-compose features
# continuing to support most of the previous docker compose features
# and flags. You can run Compose V2 by replacing the hyphen (-) with
# a space, using docker compose, instead of docker-compose.
# a space, using docker compose, instead of docker compose.
docker compose down "$1"
fi
4 changes: 2 additions & 2 deletions dc-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ done
echo "Running docker compose unit tests with profile postgres-redis and test case $TEST_CASE ..."

# Compose V2 integrates compose functions into the Docker platform,
# continuing to support most of the previous docker-compose features
# continuing to support most of the previous docker compose features
# and flags. You can run Compose V2 by replacing the hyphen (-) with
# a space, using docker compose, instead of docker-compose.
# a space, using docker compose, instead of docker compose.
echo "Building images..."
./docker/setEnv.sh integration_tests
./dc-build.sh
Expand Down
8 changes: 4 additions & 4 deletions dc-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ if [ $# -eq 0 ]
then
echo "Stopping docker compose"
# Compose V2 integrates compose functions into the Docker platform,
# continuing to support most of the previous docker-compose features
# continuing to support most of the previous docker compose features
# and flags. You can run Compose V2 by replacing the hyphen (-) with
# a space, using docker compose, instead of docker-compose.
# a space, using docker compose, instead of docker compose.
docker compose stop
else
echo "Stopping docker compose with additional parameter $1 ..."
# Compose V2 integrates compose functions into the Docker platform,
# continuing to support most of the previous docker-compose features
# continuing to support most of the previous docker compose features
# and flags. You can run Compose V2 by replacing the hyphen (-) with
# a space, using docker compose, instead of docker-compose.
# a space, using docker compose, instead of docker compose.
docker compose stop "$1"
fi
4 changes: 2 additions & 2 deletions dc-unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ fi

echo "Running docker compose unit tests with test case $TEST_CASE ..."
# Compose V2 integrates compose functions into the Docker platform, continuing to support
# most of the previous docker-compose features and flags. You can run Compose V2 by
# replacing the hyphen (-) with a space, using docker compose, instead of docker-compose.
# most of the previous docker compose features and flags. You can run Compose V2 by
# replacing the hyphen (-) with a space, using docker compose, instead of docker compose.
docker compose exec uwsgi bash -c "python manage.py test $TEST_CASE -v2 --keepdb"
4 changes: 2 additions & 2 deletions dc-up-d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ if [[ $? -eq 1 ]]; then exit 1; fi
echo "Starting docker compose in the background ..."

# Compose V2 integrates compose functions into the Docker platform, continuing to support
# most of the previous docker-compose features and flags. You can run Compose V2 by
# replacing the hyphen (-) with a space, using docker compose, instead of docker-compose.
# most of the previous docker compose features and flags. You can run Compose V2 by
# replacing the hyphen (-) with a space, using docker compose, instead of docker compose.
docker compose up --no-deps -d
4 changes: 2 additions & 2 deletions dc-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bash ./docker/docker-compose-check.sh
if [[ $? -eq 1 ]]; then exit 1; fi

# Compose V2 integrates compose functions into the Docker platform, continuing to support
# most of the previous docker-compose features and flags. You can run Compose V2 by
# replacing the hyphen (-) with a space, using docker compose, instead of docker-compose.
# most of the previous docker compose features and flags. You can run Compose V2 by
# replacing the hyphen (-) with a space, using docker compose, instead of docker compose.
docker compose up --no-deps
echo "Starting docker compose in the foreground ..."
4 changes: 2 additions & 2 deletions docker/docker-compose-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ current=$(docker compose version --short)

echo 'Checking docker compose version'
if [[ $main -lt 2 ]]; then
echo "$current is not a supported docker-compose version, please upgrade to the minimum supported version: 2.0"
echo "$current is not a supported 'docker compose' version, please upgrade to the minimum supported version: 2.0"
exit 1
elif [[ $main -eq 1 ]]; then
if [[ $minor -lt 28 ]]; then
echo "$current is not supported docker-compose version, please upgrade to minimal supported version:1.28"
echo "$current is not supported 'docker compose' version, please upgrade to minimal supported version:1.28"
exit 1
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion docker/extra_settings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ If a file if placed here, it will be copied on startup to `dojo/settings/local_s
For an example, see [template-local_settings](../../dojo/settings/template-local_settings)

Please note this copy action could fail if you have mounted the full `dojo/` folder, but that is owned by a different user/group.
That's why this copy action only happens in docker-compose release mode, and not in dev/debug/unit_tests/integration_tests modes.
That's why this copy action only happens in docker compose release mode, and not in dev/debug/unit_tests/integration_tests modes.

For advanced usage you can also place a `settings.dist.py` or `settings.py` file. These will also be copied on startup to dojo/settings.

Expand Down
14 changes: 7 additions & 7 deletions docs/content/en/contributing/how-to-write-a-parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ All commands assume that you're located at the root of the django-DefectDojo clo
- Checkout `dev` and make sure you're up to date with the latest changes.
- It's advised that you create a dedicated branch for your development, such as `git checkout -b parser-name`.

It is easiest to use the docker-compose deployment as it has hot-reload capbility for uWSGI.
It is easiest to use the docker compose deployment as it has hot-reload capbility for uWSGI.
Set up your environment to use the debug environment:

`$ docker/setEnv.sh debug`
Expand All @@ -27,7 +27,7 @@ Please have a look at [DOCKER.md](https://github.com/DefectDojo/django-DefectDoj
You will want to build your docker images locally, and eventually pass in your local user's `uid` to be able to write to the image (handy for database migration files). Assuming your user's `uid` is `1000`, then:

{{< highlight bash >}}
$ docker-compose build --build-arg uid=1000
$ docker compose build --build-arg uid=1000
{{< /highlight >}}

## Which files do you need to modify?
Expand Down Expand Up @@ -279,7 +279,7 @@ This ensures the file is closed at the end of the with statement, even if an exc

### Test database

To test your unit tests locally, you first need to grant some rights. Get your MySQL root password from the docker-compose logs, login as root and issue the following commands:
To test your unit tests locally, you first need to grant some rights. Get your MySQL root password from the docker compose logs, login as root and issue the following commands:

{{< highlight mysql >}}
MYSQL> grant all privileges on test_defectdojo.* to defectdojo@'%';
Expand All @@ -291,17 +291,17 @@ MYSQL> flush privileges;
This local command will launch the unit test for your new parser

{{< highlight bash >}}
$ docker-compose exec uwsgi bash -c 'python manage.py test unittests.tools.<your_unittest_py_file>.<main_class_name> -v2'
$ docker compose exec uwsgi bash -c 'python manage.py test unittests.tools.<your_unittest_py_file>.<main_class_name> -v2'
{{< /highlight >}}

Example for the blackduck hub parser:

{{< highlight bash >}}
$ docker-compose exec uwsgi bash -c 'python manage.py test unittests.tools.test_blackduck_csv_parser.TestBlackduckHubParser -v2'
$ docker compose exec uwsgi bash -c 'python manage.py test unittests.tools.test_blackduck_csv_parser.TestBlackduckHubParser -v2'
{{< /highlight >}}

{{% alert title="Information" color="info" %}}
If you want to run all unit tests, simply run `$ docker-compose exec uwsgi bash -c 'python manage.py test unittests -v2'`
If you want to run all unit tests, simply run `$ docker compose exec uwsgi bash -c 'python manage.py test unittests -v2'`
{{% /alert %}}

### Endpoint validation
Expand Down Expand Up @@ -330,7 +330,7 @@ In the event where you'd have to change the model, e.g. to increase a database c
* Create a new migration file in dojo/db_migrations by running and including as part of your PR

{{< highlight bash >}}
$ docker-compose exec uwsgi bash -c 'python manage.py makemigrations -v2'
$ docker compose exec uwsgi bash -c 'python manage.py makemigrations -v2'
{{< /highlight >}}

### Accept a different type of file to upload
Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/getting_started/running-in-production.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ draft: false
weight: 4
---

## Production use with docker-compose
## Production use with docker compose

The docker-compose.yml file in this repository is fully functional to evaluate DefectDojo in your local environment.

Expand Down Expand Up @@ -76,7 +76,7 @@ Dockerfile.django-* for in-file references.

You can execute the following command to see the configuration:

`docker-compose exec celerybeat bash -c "celery -A dojo inspect stats"`
`docker compose exec celerybeat bash -c "celery -A dojo inspect stats"`
and see what is in effect.

#### Asynchronous Import
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/getting_started/upgrading/2.23.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ There is a migration process built into the upgrade that will automatically conv
- If your deployment uses the MySQL containerized database, please see the following updates to run DefectDojo:
- Use of the helper script "dc-up": `./dc-up.sh mysql-rabbitmq` or `./dc-up.sh mysql-redis`
- Use of the helper script "dc-up-d": `./dc-up-d.sh mysql-rabbitmq` or `./dc-up-d.sh mysql-redis`
- Use of Docker Compose directly: `docker-compose --profile mysql-rabbitmq --env-file ./docker/environments/mysql-rabbitmq.env up` or `docker-compose --profile mysql-redis --env-file ./docker/environments/mysql-redis.env up`
- Use of Docker Compose directly: `docker compose --profile mysql-rabbitmq --env-file ./docker/environments/mysql-rabbitmq.env up` or `docker compose --profile mysql-redis --env-file ./docker/environments/mysql-redis.env up`

For all other changes, check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.23.0) for the contents of the release.
2 changes: 1 addition & 1 deletion docs/content/en/getting_started/upgrading/2.30.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ There are instructions for upgrading to 2.30.0 if you disabled `enable_auditlog`

Parameter `enable_auditlog` is not possible to set through System settings anymore. If you set this parameter or you need to change it to `False` (to disable audit logging), set environmental variable `DD_ENABLE_AUDITLOG` to `False`.

If you are using docker-compose, another EnvVar should be added to the `docker-compose.yml` file in all the containers ran by the django image. This should do the trick
If you are using docker compose, another EnvVar should be added to the `docker-compose.yml` file in all the containers ran by the django image. This should do the trick
```yaml
DD_ENABLE_AUDITLOG: ${DD_ENABLE_AUDITLOG:-False}
```
Expand Down
14 changes: 7 additions & 7 deletions docs/content/en/getting_started/upgrading/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ draft: false
weight: 5
---

## Docker-compose
## Docker compose

When you deploy a vanilla docker-compose, it will create a persistent
When you deploy a vanilla docker compose, it will create a persistent
volume for your Postgres database. As long as your volume is there, you
should not lose any data.

Expand All @@ -19,7 +19,7 @@ DockerHub to update.
{{% /alert %}}


The generic upgrade method for docker-compose are as follows:
The generic upgrade method for docker compose are as follows:
- Pull the latest version

``` {.sourceCode .bash}
Expand All @@ -41,15 +41,15 @@ The generic upgrade method for docker-compose are as follows:
docker pull defectdojo/defectdojo-nginx:1.10.2-alpine
```

- Go to the directory where your docker-compose.yml file lives
- Go to the directory where your docker compose.yml file lives
- Stop DefectDojo: `./dc-stop.sh`
- Re-start DefectDojo, allowing for container recreation:
`./dc-up-d.sh`
- Database migrations will be run automatically by the initializer.
Check the output via `docker-compose logs initializer` or relevant k8s command
Check the output via `docker compose logs initializer` or relevant k8s command
- If you have the initializer disabled (or if you want to be on the
safe side), run the migration command:
`docker-compose exec uwsgi /bin/bash -c "python manage.py migrate"`
`docker compose exec uwsgi /bin/bash -c "python manage.py migrate"`

### Building your local images

Expand All @@ -64,7 +64,7 @@ first.
git merge origin/master
```

Then replace the first step of the above generic upgrade method for docker-compose with: `docker-compose build`
Then replace the first step of the above generic upgrade method for docker compose with: `docker compose build`

## godojo installations

Expand Down
6 changes: 3 additions & 3 deletions docs/content/en/integrations/jira.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,19 @@ optional arguments:
This can be executed from the uwsgi docker container using:

{{< highlight bash >}}
$ docker-compose exec uwsgi /bin/bash -c 'python manage.py jira_status_reconciliation'
$ docker compose exec uwsgi /bin/bash -c 'python manage.py jira_status_reconciliation'
{{< /highlight >}}

DEBUG output can be obtains via `-v 3`, but only after increasing the logging to DEBUG level in your settings.dist.py or local_settings.py file

{{< highlight bash >}}
$ docker-compose exec uwsgi /bin/bash -c 'python manage.py jira_status_reconciliation -v 3'
$ docker compose exec uwsgi /bin/bash -c 'python manage.py jira_status_reconciliation -v 3'
{{< /highlight >}}

At the end of the command a semicolon seperated CSV summary will be printed. This can be captured by redirecting stdout to a file:

{{< highlight bash >}}
$ docker-compose exec uwsgi /bin/bash -c 'python manage.py jira_status_reconciliation > jira_reconciliation.csv'
$ docker compose exec uwsgi /bin/bash -c 'python manage.py jira_status_reconciliation > jira_reconciliation.csv'
{{< /highlight >}}


Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/integrations/ldap-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Read the docs for Django Authentication with LDAP here: https://django-auth-ldap

#### docker-compose.yml

In order to pass the variables to the settings.dist.py file via docker, it's a good idea to add these to the docker-compose file.
In order to pass the variables to the settings.dist.py file via docker, it's a good idea to add these to the docker compose file.

You can do this by adding the following variables to the environment section for the uwsgi image:
```yaml
Expand Down
10 changes: 5 additions & 5 deletions docs/content/en/usage/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,22 @@ to the hashcode configuration or calculation logic. We will mention this in the
To regenerate the hashcodes, use the `dedupe` management command:

{{< highlight bash >}}
docker-compose exec uwsgi ./manage.py dedupe --hash_code_only
docker compose exec uwsgi ./manage.py dedupe --hash_code_only
{{< / highlight >}}

This will only regenerated the hashcodes, but will not run any deduplication logic on existing findings.
If you want to run deduplication again on existing findings to make sure any duplicates found by the new
hashcode config are marked as such, run:

{{< highlight bash >}}
docker-compose exec uwsgi ./manage.py dedupe
docker compose exec uwsgi ./manage.py dedupe
{{< / highlight >}}

The deduplication part of this command will run the deduplication for each finding in a celery task. If you want to
run the deduplication in the foreground process, use:

{{< highlight bash >}}
docker-compose exec uwsgi ./manage.py dedupe --dedupe_sync
docker compose exec uwsgi ./manage.py dedupe --dedupe_sync
{{< / highlight >}}

Please note the deduplication process is resource intensive and can take a long time to complete
Expand Down Expand Up @@ -502,10 +502,10 @@ You can of course change this default by modifying that stanza.
### Launching from the CLI

You can also invoke the SLA notification function from the CLI. For
example, if run from docker-compose:
example, if run from docker compose:

{{< highlight bash >}}
$ docker-compose exec uwsgi /bin/bash -c 'python manage.py sla_notifications'
$ docker compose exec uwsgi /bin/bash -c 'python manage.py sla_notifications'
{{< / highlight >}}

## Reports
Expand Down
Loading

0 comments on commit a5bfd5a

Please sign in to comment.