Skip to content

Commit

Permalink
Merge pull request #90 from Full-Tortuga/config/docker
Browse files Browse the repository at this point in the history
ci: config docker deployment
  • Loading branch information
JSnow11 authored Jan 9, 2022
2 parents 6dd8de1 + 4fcecfc commit 1be0c55
Show file tree
Hide file tree
Showing 24 changed files with 190 additions and 473 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/node_modules
90 changes: 90 additions & 0 deletions decide/local_settings_docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
import os

# dev env CORS SETTINGS
BASEURL = 'http://localhost:8000'
FE_BASEURL = 'http://localhost:3000'

CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = (
BASEURL, FE_BASEURL
)
CSRF_TRUSTED_ORIGINS = [
BASEURL, FE_BASEURL
]


# Modules in use, commented modules that you won't use
MODULES = [
'administration',
'authentication',
'base',
'booth',
'census',
'mixnet',
'postproc',
'store',
'visualizer',
'voting',
]


APIS = {
'administration': BASEURL,
'authentication': BASEURL,
'base': BASEURL,
'booth': BASEURL,
'census': BASEURL,
'mixnet': BASEURL,
'postproc': BASEURL,
'store': BASEURL,
'visualizer': BASEURL,
'voting': BASEURL,
}

DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'db',
'CLIENT': {
'username': os.environ.get('MONGO_USER'),
'password': os.environ.get('MONGO_PASSWORD'),
'host': os.environ.get('MONGO_HOST'),
'port': int(os.environ.get('MONGO_PORT')),
'authSource': os.environ.get('MONGO_NAME'),
'authMechanism': 'SCRAM-SHA-1'
}
}
}

# number of bits for the key, all auths should use the same number of bits
KEYBITS = 256

# Baseline configuration.
AUTH_LDAP_SERVER_URI = 'ldap://:389'

AUTH_LDAP_BIND_DN = 'cn=admin,dc=decide,dc=org'
AUTH_LDAP_BIND_PASSWORD = 'decide'
AUTH_LDAP_USER_SEARCH = LDAPSearch(
'ou=people,dc=decide,dc=org',
ldap.SCOPE_SUBTREE,
'(uid=%(user)s)',
)

# Populate the Django user from the LDAP directory.
AUTH_LDAP_USER_ATTR_MAP = {
'first_name': 'cn',
'last_name': 'sn',
'email': 'mail',
}

# Keep ModelBackend around for per-user permissions and maybe a local
# superuser.

AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'django_auth_ldap.backend.LDAPBackend',
]
17 changes: 17 additions & 0 deletions docker-admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1
FROM python:3
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app

RUN apt-get update
RUN apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev

RUN git clone https://github.com/Full-Tortuga/decide-full-tortuga-admin.git .
RUN pip3 install -r requirements.txt

WORKDIR /app/decide

# local settings.py
ADD docker-settings.py /app/decide/local_settings.py
ADD .env /app/decide/.env
33 changes: 33 additions & 0 deletions docker-admin/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3'
services:
mongo-decide:
image: 'mongo'
environment:
- MONGO_INITDB_DATABASE=db
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
- MONGO_INITDB_USER=mongo
- MONGO_INITDB_PWD=mongo
volumes:
- ./init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh
- mongo_decide_data:/data/db
ports:
- 27017:27017
decide:
build: .
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
volumes:
- ./decide:/code
ports:
- "8000:8000"
environment:
- MONGO_NAME=db
- MONGO_USER=mongo
- MONGO_HOST=mongo-decide
- MONGO_PASSWORD=mongo
- MONGO_PORT=27017
depends_on:
- mongo-decide
volumes:
mongo_decide_data: {}

64 changes: 35 additions & 29 deletions docker/docker-settings.py → docker-admin/docker-settings.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@

import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
import os

DEBUG = True

STATIC_ROOT = '/app/static/'
MEDIA_ROOT = '/app/static/media/'
ALLOWED_HOSTS = ['*']

BASEURL = 'http://localhost'


# dev env CORS SETTINGS
BASEURL = 'http://localhost:8000'
FE_BASEURL = 'http://localhost:3000'

CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = (
BASEURL, FE_BASEURL
)
CSRF_TRUSTED_ORIGINS = [
BASEURL, FE_BASEURL
]


# Modules in use, commented modules that you won't use
Expand All @@ -28,23 +31,39 @@
'voting',
]


APIS = {
'administration': BASEURL,
'authentication': BASEURL,
'base': BASEURL,
'booth': BASEURL,
'census': BASEURL,
'mixnet': BASEURL,
'postproc': BASEURL,
'store': BASEURL,
'visualizer': BASEURL,
'voting': BASEURL,
}

DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': os.environ.get('DATABASE_NAME'),
'NAME': 'db',
'CLIENT': {
'host': os.environ.get('DATABASE_HOST'),
'username': os.environ.get('DATABASE_USER'),
'password': os.environ.get('DATABASE_PASSWORD'),
'SSL': 'true'
'username': os.environ.get('MONGO_USER'),
'password': os.environ.get('MONGO_PASSWORD'),
'host': os.environ.get('MONGO_HOST'),
'port': int(os.environ.get('MONGO_PORT')),
'authSource': os.environ.get('MONGO_NAME'),
'authMechanism': 'SCRAM-SHA-1'
}

}
}

# number of bits for the key, all auths should use the same number of bits
KEYBITS = 256

# Baseline configuration.
AUTH_LDAP_SERVER_URI = 'ldap://:389'

AUTH_LDAP_BIND_DN = 'cn=admin,dc=decide,dc=org'
Expand All @@ -61,24 +80,11 @@
'last_name': 'sn',
'email': 'mail',
}
APIS = {
'administration': 'http://10.5.0.1:8000',
'authentication': 'http://10.5.0.1:8000',
'base': 'http://10.5.0.1:8000',
'booth': 'http://10.5.0.1:8000',
'census': 'http://10.5.0.1:8000',
'mixnet': 'http://10.5.0.1:8000',
'postproc': 'http://10.5.0.1:8000',
'store': 'http://10.5.0.1:8000',
'visualizer': 'http://10.5.0.1:8000',
'voting': 'http://10.5.0.1:8000',
}

# Keep ModelBackend around for per-user permissions and maybe a local
# superuser.

AUTHENTICATION_BACKENDS = [
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
'django_auth_ldap.backend.LDAPBackend',
]

14 changes: 14 additions & 0 deletions docker-admin/init-mongo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set -e

mongo <<EOF
use $MONGO_INITDB_DATABASE
db.createUser(
{
user: "$MONGO_INITDB_USER",
pwd: "$MONGO_INITDB_PWD",
roles: [
{ role: "readWrite", db: "$MONGO_INITDB_DATABASE" }
]
})
EOF
16 changes: 0 additions & 16 deletions docker-compose.yml

This file was deleted.

31 changes: 0 additions & 31 deletions docker/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions docker/Dockerfile-nginx

This file was deleted.

54 changes: 0 additions & 54 deletions docker/docker-compose.yml

This file was deleted.

24 changes: 0 additions & 24 deletions docker/docker-nginx.conf

This file was deleted.

Loading

0 comments on commit 1be0c55

Please sign in to comment.