Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bash-script): Drop all dc- scripts #11649

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/fetch-oas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
docker images

- name: Start Dojo
run: docker compose up --no-deps -d postgres nginx uwsgi
run: docker compose up -d postgres nginx uwsgi
env:
DJANGO_VERSION: ${{ env.release_version }}-alpine
NGINX_VERSION: ${{ env.release_version }}-alpine
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ jobs:
run: ln -s docker-compose.override.integration_tests.yml docker-compose.override.yml

- name: Start Dojo
run: docker compose up --no-deps -d postgres nginx celerybeat celeryworker mailhog uwsgi redis
run: docker compose up -d postgres nginx celerybeat celeryworker mailhog uwsgi redis
env:
DJANGO_VERSION: ${{ matrix.os }}
NGINX_VERSION: ${{ matrix.os }}

- name: Initialize
timeout-minutes: 10
run: docker compose up --no-deps --exit-code-from initializer initializer
run: docker compose up --exit-code-from initializer initializer
env:
DJANGO_VERSION: ${{ matrix.os }}
NGINX_VERSION: ${{ matrix.os }}

- name: Integration tests
timeout-minutes: 10
run: docker compose up --no-deps --exit-code-from integration-tests integration-tests
run: docker compose up --exit-code-from integration-tests integration-tests
env:
DD_INTEGRATION_TEST_FILENAME: ${{ matrix.test-case }}
INTEGRATION_TESTS_VERSION: debian
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rest-framework-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
# no celery or initializer needed for unit tests
- name: Unit tests
timeout-minutes: 10
run: docker compose up --no-deps --exit-code-from uwsgi uwsgi
run: docker compose up --exit-code-from uwsgi uwsgi
env:
DJANGO_VERSION: ${{ matrix.os }}

Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ docker-compose features and flags. You can run Compose V2 by replacing the hyphe
git clone https://github.com/DefectDojo/django-DefectDojo
cd django-DefectDojo

# Check if your installed toolkit is compatible
./docker/docker-compose-check.sh

# Building Docker images
./dc-build.sh
docker compose build

# Run the application (for other profiles besides postgres-redis see
# https://github.com/DefectDojo/django-DefectDojo/blob/dev/readme-docs/DOCKER.md)
./dc-up-d.sh postgres-redis
docker compose up -d

# Obtain admin credentials. The initializer can take up to 3 minutes to run.
# Use docker compose logs -f initializer to track its progress.
Expand All @@ -64,17 +67,13 @@ docker compose logs initializer | grep "Admin password:"

## For Docker Compose V1

You can run Compose V1 by editing the files below to add the hyphen (-) between `docker compose`.
You can run Compose V1 by calling `docker-compose` (by adding the hyphen (-) between `docker compose`).

Following commands are using original version so you might need to adjust them:
```sh
dc-build.sh
dc-down.sh
dc-stop.sh
dc-unittest.sh
dc-up-d.sh
dc-up.sh
docker/docker-compose-check.sh
docker/entrypoint-initializer.sh
docker/setEnv.sh
docker/docker-compose-check.sh
docker/entrypoint-initializer.sh
docker/setEnv.sh
```

Navigate to `http://localhost:8080` to see your new instance!
Expand Down
21 changes: 0 additions & 21 deletions dc-build.sh

This file was deleted.

21 changes: 0 additions & 21 deletions dc-down.sh

This file was deleted.

21 changes: 0 additions & 21 deletions dc-stop.sh

This file was deleted.

11 changes: 0 additions & 11 deletions dc-up-d.sh

This file was deleted.

10 changes: 0 additions & 10 deletions dc-up.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ $ docker compose exec uwsgi bash -c 'python manage.py test unittests.tools.<your
or like this:

{{< highlight bash >}}
$ ./dc-unittest.sh --test-case unittests.tools.<your_unittest_py_file>.<main_class_name>
$ ./run-unittest.sh --test-case unittests.tools.<your_unittest_py_file>.<main_class_name>
{{< /highlight >}}

Example for the blackduck hub parser:
Expand All @@ -307,7 +307,7 @@ $ docker compose exec uwsgi bash -c 'python manage.py test unittests.tools.test_
or like this:

{{< highlight bash >}}
$ ./dc-unittest.sh --test-case unittests.tools.test_blackduck_csv_parser.TestBlackduckHubParser
$ ./run-unittest.sh --test-case unittests.tools.test_blackduck_csv_parser.TestBlackduckHubParser
{{< /highlight >}}

If you want to run all unit tests, simply run `$ docker-compose exec uwsgi bash -c 'python manage.py test unittests -v2'`
Expand Down
4 changes: 3 additions & 1 deletion docs/content/en/open_source/upgrading/2.43.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: 'Upgrading to DefectDojo Version 2.43.x'
toc_hide: true
weight: -20250106
description: Disclaimer field renamed/split.
description: Disclaimer field renamed/split and removal of `dc-` scripts.
---

[Pull request #10902](https://github.com/DefectDojo/django-DefectDojo/pull/10902) introduced different kinds of disclaimers within the DefectDojo instance. The original content of the disclaimer was copied to all new fields where it had been used until now (so this change does not require any action on the user's side). However, if users were managing the original disclaimer via API (endpoint `/api/v2/system_settings/1/`, field `disclaimer`), be aware that the fields are now called `disclaimer_notifications` and `disclaimer_reports` (plus there is one additional, previously unused field called `disclaimer_notes`).

In the past, when DefectDojo supported different database and message brokers, `dc-` scripts have been added to simplify start of Dojo stack. As these backends are not supported, mentioned scripts are not needed anymore. From now we recommend to use standard `docker compose` (or `docker-compose`) commands as they are described on [README.md](https://github.com/DefectDojo/django-DefectDojo/blob/master/README.md)

But there are no other special instructions for upgrading to 2.43.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.43.0) for the contents of the release.
5 changes: 2 additions & 3 deletions docs/content/en/open_source/upgrading/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ The generic upgrade method for docker compose are as follows:
```

- 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`
- Stop DefectDojo: `docker compose stop`
- Re-start DefectDojo, allowing for container recreation: `docker compose up -d`
- Database migrations will be run automatically by the initializer.
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
Expand Down
5 changes: 2 additions & 3 deletions docs/content/en/open_source/upgrading/upgrading_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ The generic upgrade method for docker compose are as follows:
```
- 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`
- Stop DefectDojo: `docker compose stop`
- Re-start DefectDojo, allowing for container recreation: `docker compose up -d`
- Database migrations will be run automatically by the initializer.
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
Expand Down
48 changes: 27 additions & 21 deletions readme-docs/DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ When running the application without building images, the application will run b

# Setup via Docker Compose

## Commands

Short summary of useful commands:

- `docker compose build` - Build the docker images, it can take additional parameters to be used in the build process, e.g. `docker compose build --no-cache`.
- `docker compose up` - Start the docker containers in the foreground.
- `docker compose up -d` - Start the docker containers in the background.
- `docker compose stop` - Stop the docker containers, it can take additional parameters to be used in the stop process.
- `docker compose down` - Stop and remove the docker containers, it can take additional parameters to be used in the stop and remove process.

## Scripts

6 shell scripts make life easier and avoid typing long commands:
2 shell scripts make life easier:

- `./dc-build.sh` - Build the docker images, it can take one additional parameter to be used in the build process, e.g. `./dc-build.sh --no-cache`.
- `./dc-up.sh` - Start the docker containers in the foreground.
- `./dc-up-d.sh` - Start the docker containers in the background.
- `./dc-stop.sh` - Stop the docker containers, it can take one additional parameter to be used in the stop process.
- `./dc-down.sh` - Stop and remove the docker containers, it can take one additional parameter to be used in the stop and remove process.
- `./dc-unittest.sh` - Utility script to aid in running a specific unit test class.
- `./run-unittest.sh` - Utility script to aid in running a specific unit test class.
- `./run-integration-tests.sh` - Utility script to aid in running a specific integration test.


# Setup via Docker Compose - Building and running the application
Expand All @@ -51,18 +57,18 @@ When running the application without building images, the application will run b
To build images and put them in your local docker cache, run:

```zsh
./dc-build.sh
docker compose build
```

To build a single image, run:

```zsh
./dc-build.sh uwsgi
docker compose build uwsgi
```
or

```
./dc-build.sh nginx
docker compose build nginx
```

> **_NOTE:_** It's possible to add extra fixtures in folder "/docker/extra_fixtures".
Expand All @@ -72,7 +78,7 @@ To run the application based on previously built image (or based on dockerhub im

```zsh
docker/setEnv.sh release
./dc-up.sh
docker compose up
```

This will run the application based on docker-compose.yml only.
Expand All @@ -86,8 +92,8 @@ For development, use:

```zsh
docker/setEnv.sh dev
./dc-build.sh
./dc-up.sh
docker compose build
docker compose up
```

This will run the application based on merged configurations from docker-compose.yml and docker-compose.override.dev.yml.
Expand Down Expand Up @@ -198,13 +204,13 @@ aedc404d6dee defectdojo/defectdojo-nginx:1.0.0 "/entrypoint-nginx.sh"
Removes all containers

```zsh
./dc-down.sh
docker compose down
```

Removes all containers, networks and the database volume

```zsh
./dc-down.sh --volumes
docker compose down --volumes
```

# Run with Docker Compose using https
Expand All @@ -231,7 +237,7 @@ chmod 400 nginx/*.key
```
rm -f docker-compose.override.yml
ln -s docker-compose.override.https.yml docker-compose.override.yml
./dc-up.sh
docker compose up
```

## Create credentials on the fly
Expand All @@ -241,7 +247,7 @@ ln -s docker-compose.override.https.yml docker-compose.override.yml
```
rm -f docker-compose.override.yml
ln -s docker-compose.override.https.yml docker-compose.override.yml
./dc-up.sh
docker compose up
```

The default https port is 8443.
Expand All @@ -267,14 +273,14 @@ This will run all unit-tests and leave the uwsgi container up:

```
docker/setEnv.sh unit_tests
./dc-up.sh
docker compose up
```

### Limited tests
If you want to enter the container to run more tests or a single test case, leave setEnv in normal or dev mode:
```
docker/setEnv.sh dev
./dc-up.sh
docker compose up
```
Then
```
Expand Down Expand Up @@ -312,10 +318,10 @@ This will run all integration-tests and leave the containers up:

```
docker/setEnv.sh integration_tests
./dc-up.sh
docker compose up
```

NB: the first time you run it, initializing the database may be too long for the tests to succeed. In that case, you'll need to wait for the initializer container to end, then re-run `./dc-up.sh`
NB: the first time you run it, initializing the database may be too long for the tests to succeed. In that case, you'll need to wait for the initializer container to end, then re-run `docker compose up`

Check the logs with:
```
Expand Down
10 changes: 5 additions & 5 deletions dc-integration-tests.sh → run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ usage() {
echo
echo
echo "Example command:"
echo './dc-unittest.sh --test-case "Finding integration tests"'
echo './run-unittest.sh --test-case "Finding integration tests"'
}

while [[ $# -gt 0 ]]; do
Expand Down Expand Up @@ -49,10 +49,10 @@ echo "Running docker compose unit tests with profile postgres-redis and test cas
# a space, using docker compose, instead of docker-compose.
echo "Building images..."
./docker/setEnv.sh integration_tests
./dc-build.sh
docker compose build
echo "Setting up DefectDojo with Postgres and Redis..."
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose --no-deps -d postgres nginx celerybeat celeryworker mailhog uwsgi redis
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose -d postgres nginx celerybeat celeryworker mailhog uwsgi redis
echo "Initializing DefectDojo..."
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose --no-deps --exit-code-from initializer initializer
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose --exit-code-from initializer initializer
echo "Running the integration tests..."
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose --no-deps --exit-code-from integration-tests integration-tests
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose --exit-code-from integration-tests integration-tests
Loading
Loading