Browse Source

docker compose setup added, README updated

b_overhaul
crunch 4 months ago
parent
commit
443eab35c1
13 changed files with 180 additions and 17 deletions
  1. +2
    -0
      .env.example
  2. +5
    -1
      .gitignore
  3. +1
    -7
      Consulta_project/Consulta_project/settings.py
  4. +0
    -0
      Consulta_project/polls/js/bundle.js
  5. +0
    -0
      Consulta_project/polls/js/stats.js
  6. +0
    -0
      Consulta_project/polls/js/stats_compiled.js
  7. +6
    -0
      Dockerfile
  8. +32
    -9
      README.md
  9. +3
    -0
      create_superuser.sh
  10. +71
    -0
      docker-compose.yml
  11. +58
    -0
      nginx.conf
  12. +2
    -0
      requirements.txt
  13. BIN
      title.png

+ 2
- 0
.env.example View File

@@ -0,0 +1,2 @@
SECRET_KEY=KCNfSB3ai9VGJ3dbuUsEh3LeVb8Zkt6wpFkM6GdnBEdi3mpduMbv7A6VyQuK59M
DB_PASSWORD=FMeKV35M9CsgMFZHZTn4YPRrswJFAzvSNt2bEDiayNeEUuoXTC3y

+ 5
- 1
.gitignore View File

@@ -120,4 +120,8 @@ dmypy.json
.pyre/

DjangoEnv
/admin
/admin

dbdata/
static_cdn/
.vscode/

+ 1
- 7
Consulta_project/Consulta_project/settings.py View File

@@ -162,13 +162,7 @@ STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]



STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]

STATIC_URL = '/static/'

# production-level static file serving (static file serving with nginx)
STATIC_ROOT = "/code/Consulta/Consulta_project/static_cdn/static_root/"
STATIC_ROOT = "/Consulta_project/static_cdn/static_root/"

Consulta_project/landing/static/js/bundle.js → Consulta_project/polls/js/bundle.js View File


Consulta_project/landing/static/js/stats.js → Consulta_project/polls/js/stats.js View File


Consulta_project/landing/static/js/stats_compiled.js → Consulta_project/polls/js/stats_compiled.js View File


+ 6
- 0
Dockerfile View File

@@ -0,0 +1,6 @@
FROM python:3
ENV PYTHONUNBUFFERED 1
WORKDIR /Consulta_project
COPY requirements.txt /Consulta_project/
RUN pip install -r requirements.txt
EXPOSE 8000

+ 32
- 9
README.md View File

@@ -1,13 +1,36 @@
# Consulta

![Consulta - Polling you can count on](title.png)
### Preface
*Consulta* is a project in the context of a bachelor's assignment at the University of Duisburg-Essen. The objective of this project is to create a basic implementation of a polling tool for use in lectures or presentations.
*Consulta* is a project in the context of a bachelor's assignment at the University of Duisburg-Essen. The objective of this project is to create a basic implementation of a polling tool for embedded use in presentations.

*Consulta* is built with [Django](https://www.djangoproject.com/), a Python Web Framework.

**Notice**: You will find documents related to this project such as a PowerPoint presentation and written report in */Misc*. Conceptual wireframes can be found in */Wireframing*

### Features
- User Management (superuser, anonymous user, registered user)
- Permission System
- Deployment via Docker
- Poll Editor (`http://$HOST/editor`)
- Sharing via QR Code (`http://$HOST/polls/$POLL_NAME/share`)
- Poll Stats via [Chart.js](https://www.chartjs.org/) (`dir: /Consulta_project/polls/js/stats.js`)
- Minimal REST API (`http://$HOST/api`) via [Django REST Framework](https://www.django-rest-framework.org/)
- Embeddable into Apple Keynote, Microsoft Powerpoint via [LiveSlides](http://liveslides.com) Chromium WebView
- Routes for toggling Poll being locked (incl. browser redirect)

Here is a wireframe of the Landing Page:
### Local Setup
Requirements:
- [Docker](https://www.docker.com/) & [Docker-Compose](https://docs.docker.com/compose/)

![Landing Page](https://git.reinkober-it.de/crunch/Consulta_Backend/raw/branch/master/Wireframing/Login_Landing_1.png)
Setup:
- `docker-compose up`

### Installation (Dev)
- execute in order: "install django_env.sh", "set_dev-env.sh", "start_dev-env.sh"
- These commands will install the environment, set the Django Environment Variable to Dev Settings
and start the local development server
Usage:
1. Visit [127.0.0.1](http://127.0.0.1)
2. Login as user "root" with the password "abc"
3. Visit the Poll Editor
4. Create a Poll with a couple of Questions, then click on "Save"
5. Select "Questions" in the Editor Interface
6. Add Answers to your Questions, then click "Save"
7. Click on "View Site" in the upper right corner
8. Have a look at your created poll
9. Vote, Share or look at your Poll's stats

+ 3
- 0
create_superuser.sh View File

@@ -0,0 +1,3 @@
#!/bin/sh

docker-compose exec django python manage.py createsuperuser

+ 71
- 0
docker-compose.yml View File

@@ -0,0 +1,71 @@
version: "3"
services:
db:
image: postgres
restart: always
environment:
POSTGRES_USER: django
POSTGRES_DB: consulta_db
POSTGRES_PASSWORD: ${DB_PASSWORD}
PGPASSWORD: ${DB_PASSWORD}
networks:
dbdata:
ipv4_address: 192.18.0.2
expose:
- "5432"
volumes:
- ./dbdata:/var/lib/postgresql/data

nginx:
image: nginx
restart: always
ports:
- "80:80"
- "443:443"
depends_on:
- django
networks:
http_net:
ipv4_address: 172.16.238.10
volumes:
#- /etc/letsencrypt/live/reinkober-it.de/cert.pem:/etc/letsencrypt/live/reinkober-it.de/cert.pem
#- /etc/letsencrypt/live/reinkober-it.de/privkey.pem:/etc/letsencrypt/live/reinkober-it.de/privkey.pem
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./static_cdn/static_root:/static
#- ./static_cdn/media:/media

django:
build: .
command: bash -c "if ! [ -d static ]; then mkdir static; fi && python manage.py makemigrations && python manage.py migrate --run-syncdb && python manage.py loaddata user_boilerplate && python manage.py collectstatic --noinput && gunicorn --bind 0.0.0.0:8000 Consulta_project.wsgi"
depends_on:
- db
environment:
- SECRET_KEY=${SECRET_KEY}
- DB_PASSWORD=${DB_PASSWORD}
networks:
dbdata:
ipv4_address: 192.18.0.5
http_net:
ipv4_address: 172.16.238.11
volumes:
- ./static_cdn/static_root/:/Consulta_project/static_cdn/static_root/
- ./Consulta_project/:/Consulta_project/
# Use this if you want to manage & enable user uploaded media
#- ./static_cdn/media/:/code/Consulta/Consulta_project/Consulta_project/media
ports:
- "8000"
restart: always

networks:
dbdata:
ipam:
config:
- subnet: 192.18.0.0/24
http_net:
ipam:
config:
- subnet: 172.16.238.0/24
default:
ipam:
config:
- subnet: 172.17.0.0/24

+ 58
- 0
nginx.conf View File

@@ -0,0 +1,58 @@
events {
worker_connections 4096; ## Default: 1024
}

http {
include mime.types;
sendfile on;

upstream gunicorn_server {
server 172.16.238.11:8000;
}
# server {
# listen 80;
# return 301 https://$host$request_uri;
#}

server {
#listen 443 ssl;
listen 80;
# ssl_certificate /etc/letsencrypt/live/reinkober-it.de/cert.pem;
# ssl_certificate_key /etc/letsencrypt/live/reinkober-it.de/privkey.pem;

root /static;
keepalive_timeout 5;
server_name ~^(.+)$;

# checks for static file, if not found proxy to app
location / {
try_files $uri @proxy_to_app;
add_header X-Frame-Options DENY;
}

# simple reverse proxy
location @proxy_to_app {
proxy_pass http://gunicorn_server;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}

# serve static files
#location ~ (images|javascript|js|css|flash|media|static)/ {
# root /var/www/reinkober-it/static/static;
# expires 30d;
#}
location /static {
alias /static;
}

location /media {
alias /media;
}
}
}

utils/requirements.txt → requirements.txt View File

@@ -1,6 +1,8 @@
Django>=2.2,<2.3
psycopg2>=2.7,<3.0
django-qr-code>=1.1,<1.2
django-guardian>=2.2.0,<2.3.0
djangorestframework>=3.11.0,<3.12.0
gunicorn>=19.9<20.0
django-cors-headers>=3.2.0,<3.3.0
django-registration>=3.1.0.,<3.2.0

BIN
title.png View File

Before After
Width: 940  |  Height: 152  |  Size: 4.7KB

Loading…
Cancel
Save