Skip to content

Commit 7896361

Browse files
Merge pull request #171 from devinmatte/docker
Adding Docker Support
2 parents 54c27fb + 7ae94c9 commit 7896361

File tree

7 files changed

+93
-63
lines changed

7 files changed

+93
-63
lines changed

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM python:3.6-stretch
2+
MAINTAINER Devin Matte <matted@csh.rit.edu>
3+
4+
RUN mkdir /opt/conditional
5+
6+
ADD requirements.txt /opt/conditional
7+
8+
WORKDIR /opt/conditional
9+
10+
RUN apt-get -yq update && \
11+
apt-get -yq install libsasl2-dev python-dev libldap2-dev libssl-dev && \
12+
pip install -r requirements.txt && \
13+
apt-get -yq clean all
14+
15+
ADD . /opt/conditional
16+
17+
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
18+
apt-get -yq update && \
19+
apt-get -yq install nodejs npm && \
20+
npm install && \
21+
npm run production && \
22+
rm -rf node_modules && \
23+
apt-get -yq remove nodejs npm && \
24+
apt-get -yq clean all
25+
26+
CMD ["gunicorn", "conditional:app", "--bind=0.0.0.0:8080", "--access-logfile=-"]

conditional/__init__.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1+
# pylint: disable=wrong-import-order
2+
from ._version import __version__
3+
14
import os
25
import subprocess
36
from datetime import datetime
47

5-
import structlog
68
from csh_ldap import CSHLDAP
79
from flask import Flask, redirect, render_template, g
810
from flask_migrate import Migrate
911
from flask_pyoidc.flask_pyoidc import OIDCAuthentication
1012
from flask_sqlalchemy import SQLAlchemy
1113
from raven.contrib.flask import Sentry
14+
import structlog
15+
16+
from conditional import config
1217

1318
app = Flask(__name__)
1419

15-
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.py")
20+
app.config.from_object(config)
21+
if os.path.exists(os.path.join(os.getcwd(), "config.py")):
22+
app.config.from_pyfile(os.path.join(os.getcwd(), "config.py"))
1623

17-
app.config.from_pyfile(config)
1824
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
1925

2026
app.config["GIT_REVISION"] = subprocess.check_output(['git',
@@ -35,6 +41,7 @@
3541

3642
app.secret_key = app.config["SECRET_KEY"]
3743

44+
3845
def start_of_year():
3946
start = datetime(datetime.today().year, 6, 1)
4047
if datetime.today() < start:
@@ -43,7 +50,7 @@ def start_of_year():
4350

4451

4552
# pylint: disable=C0413
46-
from conditional.models.models import UserLog
53+
from .models.models import UserLog
4754

4855

4956
# Configure Logging
@@ -86,19 +93,19 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse
8693

8794
from conditional.util.auth import get_user
8895

89-
from conditional.blueprints.dashboard import dashboard_bp # pylint: disable=ungrouped-imports
90-
from conditional.blueprints.attendance import attendance_bp
91-
from conditional.blueprints.major_project_submission import major_project_bp
92-
from conditional.blueprints.intro_evals import intro_evals_bp
93-
from conditional.blueprints.intro_evals_form import intro_evals_form_bp
94-
from conditional.blueprints.housing import housing_bp
95-
from conditional.blueprints.spring_evals import spring_evals_bp
96-
from conditional.blueprints.conditional import conditionals_bp
97-
from conditional.blueprints.member_management import member_management_bp
98-
from conditional.blueprints.slideshow import slideshow_bp
99-
from conditional.blueprints.cache_management import cache_bp
100-
from conditional.blueprints.co_op import co_op_bp
101-
from conditional.blueprints.logs import log_bp
96+
from .blueprints.dashboard import dashboard_bp # pylint: disable=ungrouped-imports
97+
from .blueprints.attendance import attendance_bp
98+
from .blueprints.major_project_submission import major_project_bp
99+
from .blueprints.intro_evals import intro_evals_bp
100+
from .blueprints.intro_evals_form import intro_evals_form_bp
101+
from .blueprints.housing import housing_bp
102+
from .blueprints.spring_evals import spring_evals_bp
103+
from .blueprints.conditional import conditionals_bp
104+
from .blueprints.member_management import member_management_bp
105+
from .blueprints.slideshow import slideshow_bp
106+
from .blueprints.cache_management import cache_bp
107+
from .blueprints.co_op import co_op_bp
108+
from .blueprints.logs import log_bp
102109

103110
app.register_blueprint(dashboard_bp)
104111
app.register_blueprint(attendance_bp)
@@ -114,7 +121,7 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse
114121
app.register_blueprint(co_op_bp)
115122
app.register_blueprint(log_bp)
116123

117-
from conditional.util.ldap import ldap_get_member
124+
from .util.ldap import ldap_get_member
118125

119126

120127
@app.route('/<path:path>')

conditional/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.6.1"

conditional/config.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from os import environ as env
2+
from conditional import __version__
3+
4+
# Flask config
5+
DEBUG = True if env.get("CONDITIONAL_DEBUG", "false").lower() == "true" else False
6+
HOST_NAME = env.get("CONDITIONAL_HOST_NAME", "conditional.csh.rit.edu")
7+
APP_NAME = "conditional"
8+
IP = env.get("CONDITIONAL_IP", "0.0.0.0")
9+
PORT = env.get("CONDITIONAL_PORT", 6969)
10+
11+
# DB Info
12+
SQLALCHEMY_DATABASE_URI = env.get("SQLALCHEMY_DATABASE_URI", "")
13+
14+
# LDAP config
15+
LDAP_RO = True if env.get("CONDITIONAL_LDAP_RO", "true").lower() == "true" else False
16+
LDAP_BIND_DN = env.get("CONDITIONAL_LDAP_BIND_DN", "cn=conditional,ou=Apps,dc=csh,dc=rit,dc=edu")
17+
LDAP_BIND_PW = env.get("CONDITIONAL_LDAP_BIND_PW", "")
18+
19+
# Sentry config
20+
# Do not set the DSN for local development
21+
SENTRY_CONFIG = {
22+
'dsn': env.get("CONDITIONAL_SENTRY_DSN", ""),
23+
'release': __version__,
24+
}
25+
26+
# OIDC Config
27+
OIDC_ISSUER = env.get("CONDITIONAL_OIDC_ISSUER", "https://sso.csh.rit.edu/auth/realms/csh")
28+
OIDC_CLIENT_CONFIG = {
29+
'client_id': env.get("CONDITIONAL_OIDC_CLIENT_ID", "conditional"),
30+
'client_secret': env.get("CONDITIONAL_OIDC_CLIENT_SECRET", ""),
31+
'post_logout_redirect_uris': [env.get("CONDITIONAL_OIDC_CLIENT_LOGOUT", "http://0.0.0.0:6969/logout")]
32+
}
33+
34+
# General config
35+
DUES_PER_SEMESTER = env.get("CONDITIONAL_DUES_PER_SEMESTER", 80)

config.sample.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "conditional",
3-
"version": "1.0.0",
3+
"version": "1.6.1",
44
"description": "CSH Re-evaluation (MEGA_EVALS RE:RE:LOADED)",
55
"license": "MIT",
66
"homepage": "http://csh.rit.edu/",
77
"repository": {
88
"type": "git",
9-
"url": "git://github.com/csssuf/conditional.git"
9+
"url": "git://github.com/ComputerScienceHouse/conditional.git"
1010
},
1111
"bugs": {
12-
"url": "https://github.com/csssuf/conditional/issues"
12+
"url": "https://github.com/ComputerScienceHouse/conditional/issues"
1313
},
1414
"author": "Computer Science House",
1515
"engines": {
@@ -26,7 +26,7 @@
2626
},
2727
"dependencies": {
2828
"bootstrap": "^3.3.6",
29-
"bootstrap-material-datetimepicker": "github:T00rk/bootstrap-material-datetimepicker#gh-pages",
29+
"bootstrap-material-datetimepicker": "^2.7.3",
3030
"bootstrap-sass": "^3.3.6",
3131
"bootstrap-sweetalert": "^1.0.1",
3232
"csh-material-bootstrap": "1.0.0",
@@ -35,7 +35,7 @@
3535
"dropzone": "^4.3.0",
3636
"enumify": "^1.0.4",
3737
"jquery": "^3.1.0",
38-
"load-awesome": "github:danielcardoso/load-awesome",
38+
"load-awesome": "^1.1.0",
3939
"lodash": "4.13.1",
4040
"reveal.js": "^3.3.0",
4141
"selectize": "^0.12.2",

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Flask==0.12.2
77
Flask-Migrate==2.1.1
88
Flask-pyoidc==1.2.0
99
Flask-SQLAlchemy==2.3.2
10+
gunicorn==19.7.1
1011
isort==4.3.4
1112
itsdangerous==0.24
1213
Jinja2==2.10

0 commit comments

Comments
 (0)