Skip to content

Dockerised project. #113

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:2.7.18-stretch

WORKDIR /usr/src/app
COPY . .
RUN make install
RUN python manage.py migrate
RUN python manage.py seed

CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ]
13 changes: 13 additions & 0 deletions Dockerfile-Contrast
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:2.7.18-stretch

WORKDIR /usr/src/app

COPY contrast_security.yaml /etc/contrast/contrast_security.yaml
COPY . .
RUN sed -i.bk "s/#'contrast/'contrast/g" pygoat/settings.py
RUN pip install contrast-agent
RUN make install
RUN python manage.py migrate
RUN python manage.py seed

CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,31 @@ If you want to setup DjanGoat with a PostgreSQL database, checkout the PostgreSQ
$ git checkout postgresql-database
```
The PostgreSQL branch has modified documentation and tests.
### Docker
To run DjanGoat in Docker use the following command to build
```
$ docker build -t djangoat .
```
To run execute the following
```
$ docker run -p8000:8000 djangoat
```
The Web ui will then be accessible via
http://localhost:8000

**username** : [email protected]
**password** : admin1234
#### Docker and Contrast
To enable Contrast Protect. first edit contrast_security.yaml with your agent credentials.
Then build the Docker image using Dockerfile-Contrast.
```
$ docker build -f Dockerfile-Contrast -t djangoat-contrast .
```
To run execute the following
```
$ docker run -p8000:8000 djangoat-contrast
```


### Testing
To run tests, simply run:
Expand Down
14 changes: 14 additions & 0 deletions contrast_security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
api:
url: https://eval.contrastsecurity.com/Contrast/
service_key:
api_key:
user_name:

agent:
logger:
path: /tmp/contrast_agent.log
level: INFO

security_logger:
path: /tmp/security.log
level: INFO
1 change: 1 addition & 0 deletions pygoat/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
]

MIDDLEWARE = [
#'contrast.agent.middlewares.django_middleware.DjangoMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
Expand Down