From efec629d6c87fa8e518f209ce2565f8e115c34f8 Mon Sep 17 00:00:00 2001 From: Max Neuvians Date: Mon, 8 Apr 2019 11:19:11 -0400 Subject: [PATCH 1/2] Compatibility with kubernetes (#127) * Modification for deploying on k8s * Small fix on dockerfile * Added CI workflow file * Ignore pip pinning in CI --- .github/main.workflow | 11 +++++++++++ Dockerfile | 14 +++----------- Dockerfile.build | 7 ------- docker-compose.yml | 8 -------- track/config.py | 2 +- 5 files changed, 15 insertions(+), 27 deletions(-) create mode 100644 .github/main.workflow delete mode 100644 Dockerfile.build delete mode 100644 docker-compose.yml diff --git a/.github/main.workflow b/.github/main.workflow new file mode 100644 index 0000000..3d19908 --- /dev/null +++ b/.github/main.workflow @@ -0,0 +1,11 @@ +workflow "CI" { + on = "push" + resolves = [ + "Dockerfile lint" + ] +} + +action "Dockerfile lint" { + uses = "docker://cdssnc/docker-lint" + args = "--ignore DL3013" +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7ae0629..d9bbe68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,18 @@ -MAINTAINER David Buckley +FROM python:3.5 as python-base LABEL Description="Track Web Security Compliance" Vendor="Canadian Digital Service" -FROM python:3.5 as python-base COPY requirements.txt /opt/track-web/requirements.txt COPY setup.py /opt/track-web/setup.py COPY track /opt/track-web/track COPY MANIFEST.in /opt/track-web/MANIFEST.in -# Build wheels to install into production image -# Force a build with --no-binary to get around the case where a wheel is available for python:3.5 but not python:3.5-alpine RUN pip install --upgrade pip && mkdir wheels && pip wheel --no-binary :all: -r /opt/track-web/requirements.txt -w wheels && pip wheel --no-deps /opt/track-web/ -w wheels - -FROM python:3.5-alpine -MAINTAINER David Buckley -LABEL Description="Track Digital Security Compliance" Vendor="Canadian Digital Service" - -COPY --from=python-base /wheels /wheels RUN pip install /wheels/* && rm -rf /wheels /root/.cache/pip && \ - addgroup -S track-web && adduser -S -G track-web track-web && \ + addgroup --system track-web && adduser --system --group track-web && \ mkdir -p /opt/track-web/.cache && \ chown -R track-web /opt/track-web + USER track-web:track-web EXPOSE 5000 diff --git a/Dockerfile.build b/Dockerfile.build deleted file mode 100644 index e018b8c..0000000 --- a/Dockerfile.build +++ /dev/null @@ -1,7 +0,0 @@ -FROM ubuntu:16.04 - -COPY deploy/provision.sh /opt/provision.sh -RUN sh /opt/provision.sh - -COPY deploy/build-env.sh /opt/build-env.sh -CMD ["sh", "/opt/build-env.sh", "/opt/apps/track-web"] diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 37fe88e..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3' -services: - build-env: - build: - context: . - dockerfile: Dockerfile.build - volumes: - - .:/opt/apps/track-web/ diff --git a/track/config.py b/track/config.py index f8204da..f99ddff 100644 --- a/track/config.py +++ b/track/config.py @@ -13,7 +13,7 @@ class Config: DEBUG = False TESTING = False - MONGO_URI = "mongodb://localhost:27017/track" + MONGO_URI = os.environ.get("TRACKER_MONGO_URI", "mongodb://localhost:27017/track") CACHE_TYPE = "null" @staticmethod From 3f3633d67db9ea100c768f59241ffa0e22282360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane?= Date: Mon, 8 Apr 2019 13:42:28 -0400 Subject: [PATCH 2/2] Performance Improvement add deferRender = true to improve the performance in older browsers by only creating the DOM nodes for the items that are currently being displayed on page 1. See https://datatables.net/manual/ajax --- track/static/js/tables.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/track/static/js/tables.js b/track/static/js/tables.js index 325d9f7..9108d48 100644 --- a/track/static/js/tables.js +++ b/track/static/js/tables.js @@ -8,6 +8,8 @@ var Tables = { // add common options to all renderTables requests if (!options.responsive) options.responsive = true; + if (!options.deferRender) options.deferRender = true; // Older browsers need this to load in an acceptable time frame. We may want to make it conditional in the future + var customInit = function() {}; // noop if (options.initComplete) customInit = options.initComplete;