forked from mgckind/des_ncsa
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Tornado webserver to fix subpath routing bug.
Remove help request system components.
- Loading branch information
1 parent
d1eb371
commit a3990ab
Showing
8 changed files
with
114 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,6 @@ | ||
FROM node:20 as build | ||
|
||
# RUN apt-get update && \ | ||
# apt-get install -y \ | ||
# python3-pip \ | ||
# wget \ | ||
# && rm -rf /var/lib/apt/lists/* | ||
|
||
# Basic python reqs | ||
# RUN pip3 install --no-cache-dir jira | ||
# RUN pip3 install --no-cache-dir netaddr | ||
# RUN pip3 install --no-cache-dir bcrypt | ||
# RUN pip3 install --no-cache-dir pyyaml | ||
# RUN pip3 install --no-cache-dir tornado==5.0.1 | ||
# RUN pip install --no-cache-dir jsmin | ||
|
||
# WORKDIR /tmp | ||
# ADD https://nodejs.org/dist/v12.14.1/node-v12.14.1-linux-x64.tar.xz | ||
# RUN tar -C /usr/local --strip-components 1 -xf /tmp/node-v12.14.1-linux-x64.tar.xz | ||
RUN npm install -g [email protected] | ||
|
||
# RUN useradd --create-home --shell /bin/bash des --uid 1001 | ||
# USER des | ||
WORKDIR /opt | ||
COPY --chown=des:des ./ ./ | ||
|
||
|
@@ -31,19 +11,16 @@ RUN vulcanize static/des_components/elements.html \ | |
--exclude static/bower_components/polymer/lib/legacy/ \ | ||
--out-html static/des_components/elements-built.html | ||
|
||
FROM jekyll/jekyll:3.8 | ||
## Currently jekyll/jekyll:4 fails with the error below so tag 3.8 is used instead. | ||
|
||
ENV JEKYLL_UID=1000 | ||
ENV JEKYLL_GID=1000 | ||
|
||
USER ${JEKYLL_UID} | ||
FROM python:3.9 | ||
|
||
## Install required gems | ||
COPY ./Gemfile ./Gemfile | ||
RUN bundle install | ||
RUN pip install --no-cache-dir jira | ||
RUN pip install --no-cache-dir netaddr | ||
RUN pip install --no-cache-dir bcrypt | ||
RUN pip install --no-cache-dir pyyaml | ||
RUN pip install --no-cache-dir tornado==5.0.1 | ||
RUN pip install --no-cache-dir jsmin | ||
|
||
## Copy source files | ||
COPY --from=build --chown=${JEKYLL_UID}:${JEKYLL_GID} /opt/ ./ | ||
COPY --from=build /opt/ ./ | ||
|
||
CMD ["bundle", "exec", "jekyll", "serve", "--host=0.0.0.0", "--watch", "--drafts"] | ||
CMD [ "python", "main.py" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" Settings for app""" | ||
import os | ||
DEBUG = False | ||
DIRNAME = os.path.dirname(__file__) | ||
if os.environ['APP_ROOT'] == '' or os.environ['APP_ROOT'] == '/': | ||
APP_ROOT = '' | ||
else: | ||
APP_ROOT = r'/{}/'.format(os.environ['APP_ROOT']) | ||
# Ensure string is like "/APP_ROOT" without trailing slash : | ||
APP_ROOT = os.path.normpath(APP_ROOT) | ||
STATIC_PATH = os.path.join(DIRNAME, 'static') | ||
TEMPLATE_PATH = os.path.join(DIRNAME, 'templates') | ||
import logging | ||
# log linked to the standard error stream | ||
logging.basicConfig(level=logging.DEBUG, | ||
format='%(asctime)s - %(levelname)-8s - %(message)s', | ||
datefmt='%d/%m/%Y %Hh%Mm%Ss') | ||
# console = logging.StreamHandler(sys.stderr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
import logging | ||
|
||
# Configure logging | ||
logging.basicConfig( | ||
format='%(asctime)s [%(name)-12s] %(levelname)-8s %(message)s', | ||
) | ||
log = logging.getLogger("desdm-public") | ||
try: | ||
log.setLevel(os.environ['LOG_LEVEL']) | ||
except: | ||
log.setLevel('WARNING') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
""" Main application for public release""" | ||
import tornado.auth | ||
import tornado.escape | ||
import tornado.httpserver | ||
import tornado.ioloop | ||
import tornado.options | ||
import tornado.web | ||
import tornado.log | ||
import Settings | ||
from tornado.options import define, options | ||
import os | ||
from global_vars import log | ||
|
||
define("port", default=8080, help="run on the given port", type=int) | ||
|
||
BASE_URL = os.environ['BASE_URL'] | ||
|
||
class BaseHandler(tornado.web.RequestHandler): | ||
def get_current_user(self): | ||
return self.get_secure_cookie("user") | ||
|
||
class MainHandler(tornado.web.RequestHandler): | ||
""" | ||
Class that handle most of the request, all the rest of the handling is done | ||
by page.js | ||
""" | ||
@tornado.web.asynchronous | ||
def get(self, path = ''): | ||
self.render('index.html', rootPath = r'{}/'.format(Settings.APP_ROOT)) | ||
|
||
#passwords = read_passwd_file() | ||
#if verify_password(passwords, basicauth_user, basicauth_pass): | ||
#self.render('index.html') | ||
|
||
class My404Handler(tornado.web.RequestHandler): | ||
""" | ||
Handles 404 requests, basically bust just changin the status to 404 | ||
""" | ||
def get(self): | ||
self.set_status(404) | ||
self.render('index.html', chichi=False) | ||
def post(self): | ||
self.set_status(404) | ||
self.render('index.html', chichi=False) | ||
|
||
class Application(tornado.web.Application): | ||
""" | ||
The tornado application class | ||
""" | ||
def __init__(self): | ||
# The order of the route handlers matters! | ||
handlers = [ | ||
(r"{}".format(Settings.APP_ROOT), MainHandler), | ||
(r"{}/static/(.*)".format(Settings.APP_ROOT), tornado.web.StaticFileHandler, {'path':Settings.STATIC_PATH}), | ||
(r"{}/(.*)".format(Settings.APP_ROOT), MainHandler), | ||
] | ||
settings = { | ||
"template_path":Settings.TEMPLATE_PATH, | ||
"debug":Settings.DEBUG, | ||
"default_handler_class": My404Handler, | ||
} | ||
tornado.web.Application.__init__(self, handlers, **settings) | ||
|
||
def main(): | ||
""" | ||
The main function | ||
""" | ||
tornado.options.parse_command_line() | ||
http_server = tornado.httpserver.HTTPServer(Application()) | ||
#http_server = tornado.httpserver.HTTPServer(Application(), ssl_options={"certfile": "/etc/httpd/ssl/des.crt", "keyfile": "/etc/httpd/ssl/des.key",}) | ||
http_server.listen(options.port) | ||
tornado.ioloop.IOLoop.instance().start() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.