From e0b54af95f02d5b7c2016827fdd10b797c844afc Mon Sep 17 00:00:00 2001
From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de>
Date: Tue, 31 Oct 2017 15:39:03 +0100
Subject: [PATCH] Update Dockerfile Added Todo concerning the node_modules
 folder since the node modules are located at the Project root in development

---
 .gitignore             |   1 -
 .gitlab-ci.yml         |  28 ++++++---
 .pylintrc              | 140 +++++++++++++++++++++++++++++++++++++++++
 Dockerfile             |   4 +-
 Makefile               |   5 +-
 docker-compose.yml     |  12 ++--
 grady/settings/live.py |   2 +-
 requirements.txt       |   1 +
 8 files changed, 175 insertions(+), 18 deletions(-)
 create mode 100644 .pylintrc

diff --git a/.gitignore b/.gitignore
index 1975c944..01d0435e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,4 +42,3 @@ scripts/
 
 # yarn stuff
 node_modules
-.pylintrc
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 880a1b3e..43e0b09d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -15,31 +15,45 @@ build:
                 - docker build -t $IMAGE_TAG .
                 - docker push $IMAGE_TAG
 
-test:
+
+.test_template: &test_definition
         stage: test
         image: $IMAGE_TAG
+
+test_coverage:
+        <<: *test_definition
         services:
                 - postgres:9.5
         script:
                 - coverage run manage.py test --noinput
                 - coverage report --skip-covered
 
-staging:
+test_pylint:
+        <<: *test_definition
+        script:
+                - pylint core || exit 0
+
+
+.staging_template: &staging_definition
         stage: staging
         image: docker:latest
+        only:
+                - master
+
+staging:
+        <<: *staging_definition
         environment:
                 name: review/$CI_COMMIT_REF_NAME
                 url: https://staging.grady.janmax.org
                 on_stop: staging_stop
         script:
                 - apk add --update py-pip && pip install docker-compose
-                - docker-compose up -d
+                - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+                - docker-compose pull
+                - docker-compose up -d --build
 
 staging_stop:
-        stage: staging
-        image: docker:latest
-        variables:
-                GIT_STRATEGY: none
+        <<: *staging_definition
         script:
                 - apk add --update py-pip && pip install docker-compose
                 - docker-compose rm --force --stop
diff --git a/.pylintrc b/.pylintrc
new file mode 100644
index 00000000..ba51efd0
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,140 @@
+[MASTER]
+
+# Add files or directories to the blacklist. They should be base names, not
+# paths.
+ignore=CVS, migrations, static, env, docs, manage.py
+
+# Add files or directories matching the regex patterns to the blacklist. The
+# regex matches against base names, not paths.
+ignore-patterns=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Use multiple processes to speed up Pylint.
+jobs=2
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# When enabled, pylint would attempt to guess common misconfiguration and emit
+# user-friendly hints instead of false-positive error messages
+suggestion-mode=yes
+
+# Allow loading of arbitrary C extensions. Extensions are imported into the
+# active Python interpreter and may run arbitrary code.
+unsafe-load-any-extension=no
+
+
+[MESSAGES CONTROL]
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once).You can also use "--disable=all" to
+# disable everything first and then reenable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use"--disable=all --enable=classes
+# --disable=W"
+disable=print-statement,
+        parameter-unpacking,
+        unpacking-in-except,
+        old-raise-syntax,
+        backtick,
+        long-suffix,
+        old-ne-operator,
+        old-octal-literal,
+        import-star-module-level,
+        non-ascii-bytes-literal,
+        raw-checker-failed,
+        bad-inline-option,
+        locally-disabled,
+        locally-enabled,
+        file-ignored,
+        suppressed-message,
+        useless-suppression,
+        deprecated-pragma,
+        apply-builtin,
+        basestring-builtin,
+        buffer-builtin,
+        cmp-builtin,
+        coerce-builtin,
+        execfile-builtin,
+        file-builtin,
+        long-builtin,
+        raw_input-builtin,
+        reduce-builtin,
+        standarderror-builtin,
+        unicode-builtin,
+        xrange-builtin,
+        coerce-method,
+        delslice-method,
+        getslice-method,
+        setslice-method,
+        no-absolute-import,
+        old-division,
+        dict-iter-method,
+        dict-view-method,
+        next-method-called,
+        metaclass-assignment,
+        indexing-exception,
+        raising-string,
+        reload-builtin,
+        oct-method,
+        hex-method,
+        nonzero-method,
+        cmp-method,
+        input-builtin,
+        round-builtin,
+        intern-builtin,
+        unichr-builtin,
+        map-builtin-not-iterating,
+        zip-builtin-not-iterating,
+        range-builtin-not-iterating,
+        filter-builtin-not-iterating,
+        using-cmp-argument,
+        eq-without-hash,
+        div-method,
+        idiv-method,
+        rdiv-method,
+        exception-message-attribute,
+        invalid-str-codec,
+        sys-max-int,
+        bad-python3-import,
+        deprecated-string-function,
+        deprecated-str-translate-call,
+        deprecated-itertools-function,
+        deprecated-types-field,
+        next-method-defined,
+        dict-items-not-iterating,
+        dict-keys-not-iterating,
+        dict-values-not-iterating
+
+[REPORTS]
+
+# Tells whether to display a full report or only the messages
+reports=yes
+
+# Activate the evaluation score.
+score=yes
+
+
+[REFACTORING]
+
+# Maximum number of nested blocks for function / method body
+max-nested-blocks=5
+
+
+[LOGGING]
+
+# Logging modules to check that the string format arguments are in logging
+# function parameter format
+logging-modules=logging
+
+
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=100
diff --git a/Dockerfile b/Dockerfile
index 945d8944..d56c36bc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,7 +17,7 @@ ENV PYTHONUNBUFFERED 1
 # This set is need otherwise the postgres driver wont work
 RUN apk update \
   && apk add --virtual build-deps gcc python3-dev musl-dev \
-  && apk add postgresql-dev \
+  && apk add --no-cache postgresql-dev \
   && pip install psycopg2 \
   && apk del build-deps
 
@@ -28,6 +28,8 @@ WORKDIR /code
 COPY . /code
 COPY --from=python /root/.cache /root/.cache
 COPY --from=python /words /usr/share/dict/words
+# TODO this won't be necessarry anymore once merged with development
+# since the node_modules are served form the Project Root there
 COPY --from=node   /node_modules core/static/node_modules
 
 RUN pip install -r requirements.txt && rm -rf /root/.cache
diff --git a/Makefile b/Makefile
index f9c953e4..c656b21c 100644
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,9 @@ APP_LIST ?= core grady util
 
 .PHONY: collectstatic run install migrations-check isort isort-check build-webpack
 
-collectstatic:
-	./manage.py compress
+collectstatic: # used only in production
+	./manage.py collectstatic --ignore node_modules
+	./manage.py compress --force
 
 run:
 	python manage.py runserver 0.0.0.0:8000
diff --git a/docker-compose.yml b/docker-compose.yml
index db46564a..f4bf724f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -9,12 +9,12 @@ services:
       - /bin/sh
       - -c
       - |
-        python3 manage.py compress
-        python3 manage.py collectstatic
-        python3 manage.py migrate --noinput
-        python3 manage.py loaddata core/fixtures/testdata-groups.json
-        python3 manage.py loaddata core/fixtures/testdata-user.json
-        python3 manage.py loaddata core/fixtures/testdata-core.json
+        python manage.py collectstatic --ignore node_modules --noinput --clear
+        python manage.py compress --force
+        python manage.py migrate --noinput
+        python manage.py loaddata core/fixtures/testdata-groups.json
+        python manage.py loaddata core/fixtures/testdata-user.json
+        python manage.py loaddata core/fixtures/testdata-core.json
         gunicorn --bind 0.0.0.0:8000 grady.wsgi:application
     ports:
       - "8000:8000"
diff --git a/grady/settings/live.py b/grady/settings/live.py
index c0e2938c..0bf021be 100644
--- a/grady/settings/live.py
+++ b/grady/settings/live.py
@@ -12,7 +12,7 @@ DEBUG = False
 COMPRESS_ENABLED = not DEBUG
 
 # adjust this setting to your needs
-ALLOWED_HOSTS = ['localhost', '.janmax.org']
+ALLOWED_HOSTS = ['localhost', '.grady.janmax.org']
 
 # sample postgres sql database configuration
 DATABASES = {
diff --git a/requirements.txt b/requirements.txt
index 4ae37bb7..221a034a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,3 +6,4 @@ gunicorn~=19.7.0
 psycopg2~=2.7.1
 xlrd~=1.0.0
 pytest-cov~=2.5.1
+pylint~=1.7.4
-- 
GitLab