Skip to content

Commit

Permalink
change docker settings and add documentation for it
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdss committed Nov 21, 2018
1 parent 2294d6f commit fe0c316
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 37 deletions.
12 changes: 9 additions & 3 deletions Dockerfile
Expand Up @@ -2,6 +2,8 @@
FROM ubuntu:18.04
LABEL MAINTAINER="Anand Tiwari"

ENV DJANGO_SETTINGS_MODULE=archerysecurity.settings.production

#Create archerysec folder.
RUN mkdir /archerysec

Expand Down Expand Up @@ -35,11 +37,15 @@ RUN \
#Copy all file to archerysec folder.
COPY . /archerysec

# Install requirements
RUN pip install -r requirements.txt && \
rm -rf /root/.cache

#Exposing port.
EXPOSE 8000

#Running installation file.
RUN chmod +x install.sh && ./install.sh
# Include init script
ADD ./docker-files/init.sh /sbin/init.sh

# UP & RUN application.
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
CMD ["/sbin/init.sh"]
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -103,11 +103,10 @@ sudo wget https://raw.githubusercontent.com/vulnersCom/nmap-vulners/master/vulne

## Automated installation

```$ git clone https://github.com/archerysec/archerysec.git
```
$ git clone https://github.com/archerysec/archerysec.git
$ cd archerysec
$ chmod +x install.sh
$ sudo ./install.sh
```

### Start app
Expand Down
11 changes: 0 additions & 11 deletions archerysecurity/local_settings.sample.py
Expand Up @@ -21,17 +21,6 @@
'127.0.0.1'
]

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'archerysec',
'USER': 'archerysec',
'PASSWORD': 'archerysec',
'HOST': 'db',
'PORT': 5432,
}
}

ADMINS = [
('admin', 'admin@example.com')
]
Empty file.
14 changes: 9 additions & 5 deletions archerysecurity/settings.py → archerysecurity/settings/base.py
Expand Up @@ -25,13 +25,16 @@
from django.contrib.messages import constants as messages

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '4t9wrak-z(#hb&5!m$+s&plnl0a7nme4n=pn4juks!nu@5@(7l'
BASE_DIR = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
".."
)

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = os.environ.get("DJANGO_DEBUG") == "1"

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "SET ME")

ALLOWED_HOSTS = ['*']

Expand Down Expand Up @@ -188,6 +191,7 @@
'REFRESH_TIMER',
]


try:
from archerysecurity.local_settings import *
except ImportError:
Expand Down
22 changes: 22 additions & 0 deletions archerysecurity/settings/development.py
@@ -0,0 +1,22 @@
import os
from .base import *

INTERNAL_IPS = [
'172.26.0.1',
'127.0.0.1'
]

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv("DB_NAME"),
'USER': os.getenv("DB_USER"),
'PASSWORD': os.getenv("DB_PASSWORD"),
'HOST': 'db',
'PORT': 5432,
}
}

ADMINS = [
('admin', os.getenv('DJANGO_ADMIN_EMAIL', 'admin@example.com'))
]
17 changes: 17 additions & 0 deletions archerysecurity/settings/production.py
@@ -0,0 +1,17 @@
import os
from .base import *

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv("DB_NAME"),
'USER': os.getenv("DB_USER"),
'PASSWORD': os.getenv("DB_PASSWORD"),
'HOST': 'db',
'PORT': 5432,
}
}

ADMINS = [
('admin', os.getenv('DJANGO_ADMIN_EMAIL', 'admin@example.com'))
]
4 changes: 3 additions & 1 deletion archerysecurity/urls.py
Expand Up @@ -35,7 +35,9 @@
url(r'^retirejsscanner/', include('staticscanners.retirejsscan.urls')),
url(r'^api/', include('archeryapi.urls')),
url(r'^scanapi/', include('APIScan.urls')),
url(r'^', include('Dashboard.urls')),

# Default url
url(r'', include('Dashboard.urls')),

# API authentication
url(r'^api-token-auth/', obtain_jwt_token),
Expand Down
2 changes: 1 addition & 1 deletion archerysecurity/wsgi.py
Expand Up @@ -13,7 +13,7 @@
# from whitenoise.django import DjangoWhiteNoise


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archerysecurity.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archerysecurity.settings.base")

application = get_wsgi_application()
# application = DjangoWhiteNoise(application)
29 changes: 22 additions & 7 deletions docker-compose.yml
Expand Up @@ -10,12 +10,8 @@ services:
- POSTGRES_USER=archerysec
- POSTGRES_DB=archerysec


archerysec:
# image: archerysec/archerysec:latest
build: .
# command: install.sh
command: python manage.py runserver 0.0.0.0:8008
ports:
- "8008:8008"
volumes:
Expand All @@ -27,10 +23,29 @@ services:
links:
- db
environment:
- POSTGRES_PASSWORD=archerysec
- POSTGRES_USER=archerysec
- POSTGRES_DB=archerysec
- DB_PASSWORD=archerysec
- DB_USER=archerysec
- DB_NAME=archerysec
- DJANGO_SETTINGS_MODULE=archerysecurity.settings.development
- DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY:-"SETME"}
- DJANGO_DEBUG=1

archerysec-worker:
build: .
volumes:
- .:/archerysec
depends_on:
- db
links:
- db
environment:
- DB_PASSWORD=archerysec
- DB_USER=archerysec
- DB_NAME=archerysec
- DJANGO_SETTINGS_MODULE=archerysecurity.settings.development
- DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY:-"SETME"}
- DJANGO_DEBUG=1
- ARCHERY_WORKER=True

zaproxy:
image: owasp/zap2docker-stable
Expand Down
12 changes: 12 additions & 0 deletions docker-files/init.sh
@@ -0,0 +1,12 @@
#!/bin/bash

python manage.py collectstatic --noinput
python manage.py migrate --noinput
python manage.py initadmin

if [ "$ARCHERY_WORKER" = "True" ]
then
python manage.py process_tasks
else
python manage.py runserver 0.0.0.0:8008
fi
5 changes: 0 additions & 5 deletions docker_run.sh

This file was deleted.

Empty file modified integration-test.sh 100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion manage.py
Expand Up @@ -3,7 +3,10 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archerysecurity.settings")
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
"archerysecurity.settings.base"
)
try:
from django.core.management import execute_from_command_line
except ImportError:
Expand Down

0 comments on commit fe0c316

Please sign in to comment.