You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,30 +4,105 @@ Docker compose is not intended for production use.
4
4
If you want to deploy a containerized DefectDojo to a production environment,
5
5
use the [Helm and Kubernetes](KUBERNETES.md) approach.
6
6
7
-
## Setup via Docker Compose
7
+
## Prerequisites
8
+
* Docker version
9
+
* Installing with docker-compose requires at least docker 18.09.4 and docker-compose 1.24.0. See "Checking Docker versions" below for version errors during running docker-compose.
10
+
* Proxies
11
+
* If you're behind a corporate proxy check https://docs.docker.com/network/proxy/ .
8
12
9
-
To start your DefectDojo instance on Docker Compose for the first time, just
10
-
run:
13
+
14
+
## Setup via Docker Compose - introduction
15
+
16
+
DefectDojo needs several docker images to run. Two of them depend on DefectDojo code:
17
+
18
+
* django service - defectdojo/defectdojo-django image
19
+
* nginx service - defectdojo/defectdojo-nginx image
20
+
21
+
The nginx image is build based on the django image.
22
+
23
+
Before running the application, it's advised to build local images to make sure that you'll be working on images consistent with your current code base.
24
+
When running the application without building images, the application will run based on:
25
+
* a previously locally built image if it exists in the docker cache
## Setup via Docker Compose - building and running the application
32
+
### Building images
33
+
34
+
To build images and put them in your local docker cache, run:
11
35
12
36
```zsh
13
-
. docker/aliases_release.sh
14
-
docker-compose up
37
+
docker-compose build
15
38
```
16
39
40
+
To build a single image, run:
41
+
42
+
```zsh
43
+
docker-compose build django
44
+
```
17
45
or
18
46
47
+
```
48
+
docker-compose build nginx
49
+
```
50
+
51
+
52
+
### Run with Docker compose in release mode
53
+
To run the application based on previously built image (or based on dockerhub images if none was locally built), run:
54
+
19
55
```zsh
20
-
docker-compose -f docker-compose_base.yml -f docker-compose_uwsgi-release.yml up
56
+
docker/setEnv.sh release
57
+
docker-compose up
21
58
```
22
59
23
-
This command will run the application based on images commited on dockerhub (or the last images built locally). If you need to be more up to date, see "Build images locally" below
60
+
This will run the application based on docker-compose.yml only.
61
+
62
+
In this setup, you need to rebuild django and/or nginx images after each code change and restart the containers.
24
63
25
-
**NOTE:** Installing with docker-compose requires the latest version of docker and docker-compose - at least docker 18.09.4 and docker-compose 1.24.0. See "Checking Docker versions" below for version errors during running docker-compose up.
26
64
27
-
**NOTE:** Installing with docker-compose requires the latest version of docker and docker-compose - at least docker 18.09.4 and docker-compose 1.24.0. See "Checking Docker versions" below for version errors during running docker-compose up.
65
+
### Run with Docker compose in development mode with hot-reloading
This will run the application based on merged configurations from docker-compose.yml and docker-compose.override.dev.yml.
76
+
77
+
* Volumes are mounted to synchronize between the host and the containers :
78
+
* static resources (nginx container)
79
+
* python code (uwsgi and celeryworker containers).
80
+
81
+
* The `--py-autoreload 1` parameter in entrypoint-uwsgi-dev.sh will make uwsgi handle python hot-reloading for the **uwsgi** container.
82
+
* Hot-reloading for the **celeryworker** container is not yet implemented. When working on deduplication for example, restart the celeryworker container with:
83
+
84
+
```
85
+
docker restart django-defectdojo_celeryworker_1
86
+
```
87
+
88
+
* The mysql port is forwarded to the host so that you can access your database from outside the container.
89
+
90
+
To update changes in static resources, served by nginx, just refresh the browser with ctrl + F5.
91
+
92
+
93
+
*Notes about volume permissions*
94
+
95
+
*The manual copy of settings.py is sometimes required once after cloning the repository, on linux hosts when the host files cannot be modified from within the django container. In that case that copy in entrypoint-uwsgi-dev.sh fails.*
96
+
97
+
*Another way to fix this is changing `USER 1001` in Dockerfile.django to match your user uid and then rebuild the images. Get your user id with*
98
+
99
+
```
100
+
id -u
101
+
```
102
+
103
+
### Access the application
29
104
Navigate to <http://localhost:8080> where you can log in with username admin.
30
-
To find out the admin user’s password, check the very beginning of the console
105
+
To find out the admin password, check the very beginning of the console
31
106
output of the initializer container, typically name 'django-defectdojo_initializer_1', or run the following:
32
107
33
108
```zsh
@@ -43,45 +118,38 @@ or:
43
118
docker logs django-defectdojo_initializer_1
44
119
```
45
120
46
-
If you ran DefectDojo with compose before and you want to prevent the
47
-
initializer container from running again, define an environment variable
48
-
DD_INITIALIZE=false to prevent re-initialization.
49
-
50
-
### Develop with Docker Compose
51
-
52
-
For developing the easiset way to make changes is to startup DefectDojo in debug by running:
121
+
Beware that when re-running the application several times, there may be several occurrences of "Admin password". In that case you should use the last occurrence.
53
122
54
-
```zsh
55
-
. docker/aliases_dev.sh
56
-
docker-compose up
57
-
```
123
+
### Disable the database initialization
124
+
The initializer container can be disabled by exporting: `export DD_INITIALIZE=false`.
58
125
59
-
or
126
+
This will ensure that the database remains unchanged when re-running the application, keeping your previous settings and admin password.
60
127
61
-
```zsh
62
-
docker-compose -f docker-compose_base.yml -f docker-compose_uwsgi-dev.yml up
63
-
```
128
+
### Versioning
129
+
In order to use a specific version when building the images and running the containers, set the environment with
130
+
* For the nginx image: `NGINX_VERSION=x.y.z`
131
+
* For the django image: `DJANGO_VERSION=x.y.z`
64
132
65
-
This starts the DefectDojo (uwsgi) container with manage.py and shares the local source directory so that changes to the code immediately restart the process.
133
+
Building will tag the images with "x.y.z", then you can run the application based on a specific tagged images.
66
134
67
-
Navigate to the container directly, <http://localhost:8000>
135
+
* Tagged images can be seen with:
68
136
69
-
The initializer container can be disabled by exporting: `export DD_INITIALIZE=false`
137
+
```
138
+
$ docker images
139
+
REPOSITORY TAG IMAGE ID CREATED SIZE
140
+
defectdojo/defectdojo-nginx 1.0.0 bc9c5f7bb4e5 About an hour ago 191MB
141
+
```
70
142
71
-
### Build Images Locally
143
+
* This will show on which tagged images the containers are running:
72
144
73
-
Build the docker containers locally for testing purposes.
145
+
```
146
+
$ docker ps
147
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
148
+
aedc404d6dee defectdojo/defectdojo-nginx:1.0.0 "/entrypoint-nginx.sh" 2 minutes ago Up 2 minutes 80/tcp, 0.0.0.0:8080->8080/tcp django-defectdojo_nginx_1
In this case, both docker (version 17.09.0-ce) and docker-compose (1.18.0) need to be updated.
131
236
132
-
Follow [Dockers' documentation](https://docs.docker.com/install/) for your OS to get the lastest version of Docker. For the docker command, most OSes have a built-in update mechanism like "apt upgrade".
237
+
Follow [Dockers' documentation](https://docs.docker.com/install/) for your OS to get the latest version of Docker. For the docker command, most OSes have a built-in update mechanism like "apt upgrade".
133
238
134
239
Docker Compose isn't packaged like Docker and you'll need to manually update an existing install if using Linux. For Linux, either follow the instructions in the [Docker Compose documentation](https://docs.docker.com/compose/install/) or use the shell script below. The script below will update docker-compose to the latest version automatically. You will need to make the script executable and have sudo privileges to upgrade docker-compose:
135
240
@@ -147,7 +252,7 @@ echo "Note: docker-compose version $VERSION will be downloaded from:"
Copy file name to clipboardExpand all lines: PULL_REQUEST_TEMPLATE.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ Please submit your pull requests to the 'dev' branch.
2
2
3
3
When submitting a pull request, please make sure you have completed the following checklist:
4
4
5
-
-[ ] Your code is flake8 compliant (DefectDojo's code isn't currently flake8 compliant, but we're trying to correct that.)
5
+
-[ ] Your code is flake8 compliant
6
6
-[ ] If this is a new feature and not a bug fix, you've included the proper documentation in the ReadTheDocs documentation folder. https://github.com/DefectDojo/Documentation/tree/master/docs or provide feature documentation in the PR.
7
-
-[ ] Model changes should include the necessary migrations in the dojo/dd_migrations folder.
7
+
-[ ] Model changes must include the necessary migrations in the dojo/dd_migrations folder.
0 commit comments