Skip to content

Commit

Permalink
Merge f29c470 into a244dd5
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Jan 9, 2020
2 parents a244dd5 + f29c470 commit ecc07d2
Show file tree
Hide file tree
Showing 300 changed files with 17,928 additions and 6,077 deletions.
7 changes: 7 additions & 0 deletions .babelrc
@@ -0,0 +1,7 @@
{
"comments":false,
"compact":true,
"presets":[
"@babel/preset-env"
]
}
8 changes: 8 additions & 0 deletions .dockerignore
@@ -0,0 +1,8 @@
/media
/static
/node_modules
/deployment
/log
.gitignore
.dockerignore
.vault_password.txt
7 changes: 5 additions & 2 deletions .gitignore
Expand Up @@ -29,10 +29,13 @@ local.py
/langerak.sublime-project

# dependencies
src/langerak_gkv/static/vendor/
node_modules
/node_modules

# testing
.coverage
/htmlcov
/reports

# Build artifacts
src/langerak_gkv/static/css/
src/langerak_gkv/static/js/
93 changes: 93 additions & 0 deletions .jshintrc
@@ -0,0 +1,93 @@
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details

"maxerr" : 50, // {int} Maximum error before stopping

// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"latedef" : false, // true: Require variables/functions to be defined before being used
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"noempty" : true, // true: Prohibit use of empty blocks
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
"plusplus" : false, // true: Prohibit use of `++` and `--`
"quotmark" : "single", // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : true, // Unused variables:
// true : all variables, last function parameter
// "vars" : all variables only
// "strict" : all variables, all function parameters
"strict" : false, // true: Requires all functions run in ES5 Strict Mode
"maxparams" : false, // {int} Max number of formal params allowed per function
"maxdepth" : 3, // {int} Max depth of nested blocks (within functions)
"maxstatements" : false, // {int} Max number statements per function
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
"maxlen" : false, // {int} Max number of characters per line
"varstmt" : false, // true: Disallow any var statements. Only `let` and `const` are allowed.

// Relaxing
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"esversion" : 6, // {int} Specify the ECMAScript version to which the code must adhere.
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
// (ex: `for each`, multiple try/catch, function expression�)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
"funcscope" : false, // true: Tolerate defining variables inside control statements
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"iterator" : false, // true: Tolerate using the `__iterator__` property
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"laxcomma" : false, // true: Tolerate comma-first style coding
"loopfunc" : false, // true: Tolerate functions being defined in loops
"multistr" : false, // true: Tolerate multi-line strings
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
"notypeof" : false, // true: Tolerate invalid typeof operator values
"proto" : false, // true: Tolerate using the `__proto__` property
"scripturl" : false, // true: Tolerate script-targeted URLs
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
"validthis" : false, // true: Tolerate using this in a non-constructor function

// Environments
"browser" : true, // Web Browser (window, document, etc)
"browserify" : false, // Browserify (node.js code in the browser)
"couch" : false, // CouchDB
"devel" : true, // Development/debugging (alert, confirm, etc)
"dojo" : false, // Dojo Toolkit
"jasmine" : false, // Jasmine
"jquery" : false, // jQuery
"mocha" : true, // Mocha
"mootools" : false, // MooTools
"node" : true, // Node.js
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
"phantom" : false, // PhantomJS
"prototypejs" : false, // Prototype and Scriptaculous
"qunit" : false, // QUnit
"rhino" : false, // Rhino
"shelljs" : false, // ShellJS
"typed" : false, // Globals for typed array constructions
"worker" : false, // Web Workers
"wsh" : false, // Windows Scripting Host
"yui" : false, // Yahoo User Interface

// Custom Globals
"globals": {
"google": true
}
}
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,7 +1,7 @@
language: python

python:
- "2.7"
- "3.6"

cache:
directories:
Expand Down
50 changes: 50 additions & 0 deletions Dockerfile
@@ -0,0 +1,50 @@
# Stage 1 - Compile needed python dependencies
FROM python:3.6-stretch AS build

RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY ./requirements /app/requirements
RUN pip install pip setuptools -U
RUN pip install -r requirements/production.txt

# Stage 2 - build frontend
FROM mhart/alpine-node:10 AS frontend-build

WORKDIR /app

COPY ./*.json /app/
RUN npm ci

# Stage 3 - Build docker image suitable for execution and deployment
FROM python:3.6-stretch AS production

# Stage 3.1 - Set up the needed production dependencies
# install all the dependencies for GeoDjango
RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /usr/local/lib/python3.6 /usr/local/lib/python3.6
COPY --from=build /usr/local/bin/uwsgi /usr/local/bin/uwsgi
COPY --from=frontend-build /app/node_modules /app/node_modules

# Stage 3.2 - Copy source code
WORKDIR /app
COPY ./bin/uwsgi.sh /uwsgi.sh
RUN mkdir /app/log

COPY ./src /app/src

ENV DJANGO_SETTINGS_MODULE=langerak_gkv.conf.production

ARG SECRET_KEY=dummy

# Run collectstatic, so the result is already included in the image
RUN python src/manage.py collectstatic --noinput

EXPOSE 8000
CMD ["/uwsgi.sh"]
5 changes: 2 additions & 3 deletions README.rst
Expand Up @@ -49,18 +49,17 @@ below.

3. Create the virtual environment and install all required libraries.::

$ mkvirtualenv -p python2.7 koningskerk
$ mkvirtualenv -p python2.6 koningskerk
$ pip install -r requirements/development.txt
$ npm install

4. Activate your virtual environment and create the statics and database::

$ workon koningskerk
$ python src/manage.py collectstatic --link --noinput
$ python src/manage.py migrate

Extra services required
-----------------------

* PostgreSQL 9.2+
* PostgreSQL 9.5+
* Elasticsearch 2.4
24 changes: 24 additions & 0 deletions bin/build_image.sh
@@ -0,0 +1,24 @@
#!/bin/bash

set -ex

CONTAINER_REPO=regexit/kerkwebsite

tag=${1:-latest}

push=${PUSH:-}

toplevel=$(git rev-parse --show-toplevel)
cd $toplevel

docker build \
--target production \
-t ${CONTAINER_REPO}:$tag \
-f Dockerfile .
echo "Image built"

if [[ $PUSH ]]; then
docker push ${CONTAINER_REPO}:$tag
echo "Image pushed"
fi

32 changes: 32 additions & 0 deletions bin/uwsgi.sh
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

# Wait for the database (container)
# See: https://docs.docker.com/compose/startup-order/
PGHOST=${DB_HOST:-db}
PGPORT=${DB_PORT:-5432}

until pg_isready ; do
>&2 echo "Waiting for database connection..."
sleep 3
done

>&2 echo "Database is up."

# Apply database migrations
>&2 echo "Apply database migrations"
python src/manage.py migrate

# Start server
>&2 echo "Starting server"
uwsgi \
--http :${UWSGI_PORT:-8000} \
--module wsgi \
--static-map /static=/app/static \
--static-map /media=/app/media \
--chdir src \
--processes 2 \
--threads 2 \
--buffer-size=32768
# processes & threads are needed for concurrency without nginx sitting inbetween
63 changes: 63 additions & 0 deletions build/paths.js
@@ -0,0 +1,63 @@
var path = require('path');
var fs = require('fs');


/** Parses package.json */
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));

/** Name of the sources directory */
var sourcesRoot = 'src/' + pkg.name + '/';

/** Name of the static (source) directory */
var staticRoot = sourcesRoot + 'static/';


/**
* Application path configuration for use in frontend scripts
*/
module.exports = {
// Parsed package.json
package: pkg,

// Path to the sass (sources) directory
sassSrcDir: sourcesRoot + 'sass/',

// Path to the sass (sources) entry point
sassSrc: sourcesRoot + 'sass/**/*.scss',

// Path to the (transpiled) css directory
cssDir: staticRoot + 'css/',

// Path to the fonts directory
fontsDir: staticRoot + 'fonts/',

// Path to the js entry point (source)
jsEntry: sourcesRoot + 'js/index.js',

// Path to the js (sources) directory
jsSrcDir: sourcesRoot + 'js/',

// Path to js (sources)
jsSrc: sourcesRoot + 'js/**/*.js',

// Path to the js (sources) directory
jsSrcDir: sourcesRoot + 'js/',

// Path to the (transpiled) js directory
jsDir: staticRoot + 'js/',

// Path to js spec (test) files
jsSpec: sourcesRoot + 'jstests/**/*.spec.js',

// Path to js spec (test) entry file
jsSpecEntry: sourcesRoot + 'jstests/index.js',

// Path to js code coverage directory
coverageDir: 'reports/jstests/',

// Path to HTML templates directory
htmlTemplatesDir: sourcesRoot + 'templates/views',

// Path to HTML includes directory
htmlIncludesDir: sourcesRoot + 'templates/components/'
};
8 changes: 8 additions & 0 deletions build/tasks/build.js
@@ -0,0 +1,8 @@
const gulp = require('gulp');
const {js} = require('./js');
const {scss} = require('./scss');

const build = gulp.parallel(js, scss);

gulp.task('build', build);
exports.build = build;

0 comments on commit ecc07d2

Please sign in to comment.