Skip to content

Commit 92aab0a

Browse files
committed
Fix docker run codepath
1 parent 9e560a5 commit 92aab0a

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ docker run \
2020
-t featureservice
2121
```
2222

23-
The first time that you run this command, it will take a while as your Postgres
24-
on Azure instance is getting populated with over 2GB of global geo-spatial
25-
features.
23+
The first time that you run this command, it will take about 90 minutes while
24+
your Postgres on Azure instance is getting populated with over 2GB of global
25+
geo-spatial features and appropriate indices are being built. On subsequent
26+
runs, the start should be instantaneous.
2627

2728
After starting the service, you will be able to call the featureService, for
2829
example via the following requests:

docker-entrypoint.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ run_sql() {
77
--username="${FEATURES_DB_USER}" \
88
--port="${FEATURES_DB_PORT}" \
99
--host="${FEATURES_DB_HOST}" \
10-
--dbname="$1" \
10+
--dbname="$1"
1111
}
1212

1313
load_features_dump() {
@@ -41,6 +41,9 @@ if [ -z "${FEATURES_DB_USER}" ]; then fail "Need to provide FEATURES_DB_USER env
4141
if [ -z "${FEATURES_DB_PASSWORD}" ]; then fail "Need to provide FEATURES_DB_PASSWORD environment variable"; fi
4242
if [ -z "${FEATURES_DB_HOST}" ]; then fail "Need to provide FEATURES_DB_HOST environment variable"; fi
4343

44+
username="${FEATURES_DB_USER%@*}"
45+
hostname="${FEATURES_DB_USER#*@}"
46+
4447
if ! features_database_exists; then
4548
dump_file="/tmp/db.fc.gz"
4649

@@ -50,8 +53,8 @@ if ! features_database_exists; then
5053
echo "CREATE USER frontend WITH login password 'changeme';" | run_sql 'postgres'
5154
echo "ALTER USER ops WITH password '${FEATURES_DB_PASSWORD}';" | run_sql 'postgres'
5255
echo "ALTER USER frontend WITH password '${FEATURES_DB_PASSWORD}';" | run_sql 'postgres'
53-
echo "GRANT ops TO ${FEATURES_DB_USER%@*};" | run_sql 'postgres'
54-
echo "GRANT frontend TO ${FEATURES_DB_USER%@*};" | run_sql 'postgres'
56+
echo "GRANT ops TO ${username};" | run_sql 'postgres'
57+
echo "GRANT frontend TO ${username};" | run_sql 'postgres'
5558
log "...done, database is now set up"
5659

5760
log "Setting up schema..."
@@ -76,5 +79,5 @@ if ! features_database_exists; then
7679
log "...done, query planner is now ready"
7780
fi
7881

79-
FEATURES_CONNECTION_STRING="postgres://frontend:${FEATURES_DB_PASSWORD}@${FEATURES_DB_HOST}:${FEATURES_DB_PORT}/${FEATURES_DB_NAME}?ssl=true" \
82+
FEATURES_CONNECTION_STRING="postgres://frontend@${hostname}:${FEATURES_DB_PASSWORD}@${FEATURES_DB_HOST}:${FEATURES_DB_PORT}/${FEATURES_DB_NAME}?ssl=true" \
8083
npm start

services/postgres.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const
44
HttpStatus = require('http-status-codes'),
55
common = require('service-utils'),
66
ServiceError = common.utils.ServiceError,
7+
config = require('../config'),
78
url = require('url');
89

910
function init(callback) {
@@ -15,16 +16,14 @@ function init(callback) {
1516
const query = querystring.parse(params.query);
1617
const auth = params.auth.split(':');
1718

18-
const config = {
19+
const featureDatabasePool = new pg.Pool({
1920
user: auth[0],
2021
password: auth[1],
2122
host: params.hostname,
2223
port: params.port,
2324
ssl: query['ssl'],
2425
database: params.pathname.split('/')[1]
25-
};
26-
27-
const featureDatabasePool = new pg.Pool(config);
26+
});
2827

2928
return callback(null, featureDatabasePool);
3029
}

0 commit comments

Comments
 (0)