From 20da6502ccf7da6bd4b3865c9ae2cb1bcbcd0c13 Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Mon, 21 Dec 2015 15:18:12 +0200 Subject: [PATCH 1/5] Preliminary Dockerfile --- Dockerfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7ea45522 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM node:5.1 +MAINTAINER Pelias + +EXPOSE 3100 +LABEL io.openshift.expose-services 3100:http + +# Where the app is built and run inside the docker fs +ENV WORK=/opt/pelias + +# Used indirectly for saving npm logs etc. +ENV HOME=/opt/pelias + +WORKDIR ${WORK} +ADD . ${WORK} + +# Build and set permissions for arbitary non-root user +RUN npm install && \ + npm test && \ + chmod -R a+rwX . + +# Don't run as root, because there's no reason to (https://docs.docker.com/engine/articles/dockerfile_best-practices/#user). +# This also reveals permission problems on local Docker. +RUN chown -R 9999:9999 ${WORK} +USER 9999 + +CMD npm start From cff28174b98adc99a1b8860c2d2b7f62e2443c37 Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Mon, 21 Dec 2015 15:40:17 +0200 Subject: [PATCH 2/5] Use older Node version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7ea45522..6ab84169 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:5.1 +FROM node:0.12 MAINTAINER Pelias EXPOSE 3100 From 96817994f657084354bd53694cba0903a023121f Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Tue, 22 Dec 2015 12:02:34 +0200 Subject: [PATCH 3/5] add default config --- Dockerfile | 2 ++ pelias.json.docker | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 pelias.json.docker diff --git a/Dockerfile b/Dockerfile index 6ab84169..5b07acd6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,8 @@ RUN npm install && \ npm test && \ chmod -R a+rwX . +ADD pelias.json.docker pelias.json + # Don't run as root, because there's no reason to (https://docs.docker.com/engine/articles/dockerfile_best-practices/#user). # This also reveals permission problems on local Docker. RUN chown -R 9999:9999 ${WORK} diff --git a/pelias.json.docker b/pelias.json.docker new file mode 100644 index 00000000..7d012f02 --- /dev/null +++ b/pelias.json.docker @@ -0,0 +1,18 @@ +{ + "esclient": { + "hosts": [ + { + "env": "production", + "protocol": "http", + "host": "pelias-data-container", + "port": 9200 + }, + { + "env": "production", + "protocol": "http", + "host": "pelias-data-container", + "port": 9300 + } + ] + } +} From 18de8b56990c8317058a865a9c77d49b16e31031 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 8 Feb 2016 18:04:34 -0500 Subject: [PATCH 4/5] Remove unused test examples --- test/unit/sanitiser/_ids.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/unit/sanitiser/_ids.js b/test/unit/sanitiser/_ids.js index 176c981a..98237180 100644 --- a/test/unit/sanitiser/_ids.js +++ b/test/unit/sanitiser/_ids.js @@ -2,10 +2,6 @@ var sanitize = require('../../../sanitiser/_ids'); var delimiter = ':'; var type_mapping = require('../../../helper/type_mapping'); -var inputs = { - valid: [ 'geoname:1', 'osmnode:2', 'admin0:53', 'osmway:44', 'geoname:5' ], - invalid: [ ':', '', '::', 'geoname:', ':234', 'gibberish:23' ] -}; var formatError = function(input) { return 'id `' + input + ' is invalid: must be of the format source:layer:id for ex: \'geonames:venue:4163334\''; From 0e78167f17bd4c4b30697d5a920054f4434d97f4 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 8 Feb 2016 18:17:38 -0500 Subject: [PATCH 5/5] [/place] Accept any valid layer for geonames Instead of checking if the source/layer combination for geonames is valid, always use the geoname type if the source is set to geonames, regardless of which layer is in the gid. This helps us better handle the case where people directly take gids from our API responses. Note: this functionality shouldn't be permanent and should be removed once our new source/layer mapping system is in. --- sanitiser/_ids.js | 8 +++++++- test/unit/sanitiser/_ids.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/sanitiser/_ids.js b/sanitiser/_ids.js index 73f9d68a..47c95ad6 100644 --- a/sanitiser/_ids.js +++ b/sanitiser/_ids.js @@ -45,7 +45,13 @@ function sanitizeId(rawId, messages) { return; } - var types = type_mapping.source_and_layer_to_type(source, layer); + //TODO: remove this once we have a better set of layers for Geonames + var types; + if (source === 'gn' || source === 'geonames') { + types = ['geoname']; + } else { + types = type_mapping.source_and_layer_to_type(source, layer); + } return { id: id, diff --git a/test/unit/sanitiser/_ids.js b/test/unit/sanitiser/_ids.js index 98237180..40af368f 100644 --- a/test/unit/sanitiser/_ids.js +++ b/test/unit/sanitiser/_ids.js @@ -122,6 +122,34 @@ module.exports.tests.valid_ids = function(test, common) { }); }; +module.exports.tests.geonames = function(test, common) { + test('geonames venue maps correctly as normal', function(t) { + var raw = { ids: 'geonames:venue:15' }; + var clean = {}; + + var messages = sanitize( raw, clean); + + var expected_clean = { ids: [ { id: '15', types: [ 'geoname' ] } ] }; + t.deepEqual( messages.errors, [], 'no errors' ); + t.deepEqual( messages.warnings, [], 'no warnings' ); + t.deepEqual(clean, expected_clean, 'clean set correctly'); + t.end(); + }); + + test('arbitrary geonames layer maps to geoname type', function(t) { + var raw = { ids: 'geonames:address:16' }; // geonames technically has no address records! + var clean = {}; + + var messages = sanitize( raw, clean); + + var expected_clean = { ids: [ { id: '16', types: [ 'geoname' ] } ] }; + t.deepEqual( messages.errors, [], 'no errors' ); + t.deepEqual( messages.warnings, [], 'no warnings' ); + t.deepEqual(clean, expected_clean, 'clean set correctly'); + t.end(); + }); +}; + module.exports.tests.multiple_ids = function(test, common) { test('multiple ids', function(t) { var raw = { ids: 'geonames:venue:1,osm:venue:2' };