Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make XML map config primary #138

Merged
merged 5 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ AWS_PROFILE
# $USER will be appended to the project name specified here
PROJECT_NAME=

# Example production credentials
# These get templated in to your map-config.mml file
# when configuration files are built.
#PROD_TILEGARDEN_DB=
#PROD_TILEGARDEN_HOST=
#PROD_TILEGARDEN_PASSWORD=
#PROD_TILEGARDEN_USER=
# Database credentials
# These get set on the Lambda function and templated into your map-config.xml file at runtime.
#TILEGARDEN_DB_NAME=
#TILEGARDEN_DB_HOST=
#TILEGARDEN_DB_PORT=
#TILEGARDEN_DB_USER=
#TILEGARDEN_DB_PASSWORD=

# Function config information
## REQUIRED ##
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,3 @@ typings/
.directory
.idea

# configs, if generated
transpiled-configs/
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ branches:
language: node_js
before_install: cd src/tiler
install: yarn install
before_script: yarn compile
script: yarn test
deploy:
- provider: script
Expand Down
10 changes: 2 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ services:
ports:
- "3000:3000"
- "9229:9229"
environment:
- DEV_TILEGARDEN_USER=postgres
- DEV_TILEGARDEN_PASSWORD=postgres
- DEV_TILEGARDEN_DB=postgres
- DEV_TILEGARDEN_HOST=database.lambnik.azavea.com
- PROJECT_NAME=${PROJECT_NAME}-${USER}
env_file: .env
env_file: .env.local
links:
- database:database.lambnik.azavea.com
- database:database.internal.tilegarden
volumes:
- ./src/tiler:/home/tiler
- node_modules:/home/tiler/node_modules
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -e

# cli args
in_dir='src/tiler/src/config/'
out_dir='transpiled-configs/'
in_dir='src/tiler/src/config/carto/'
out_dir='src/tiler/src/config/'
s3_bucket=''
node_env='production'

Expand Down
18 changes: 4 additions & 14 deletions scripts/server
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,17 @@ COMMAND can be one of [start, stop, restart, status]. Default is start.
}


function restart_services() {
SERVICES=${@:2}

echo "Restarting service(s) in background..."
docker-compose restart ${SERVICES}
echo "Waiting for services to restart..."
sleep 5
}


function main() {

SERVICES='tiler database'
if [ "${1}" = "start" ]
then
docker-compose up
docker-compose up ${SERVICES}
elif [ "${1}" = "stop" ]
then
docker-compose stop
docker-compose stop ${SERVICES}
elif [ "${1}" = "restart" ]
then
docker-compose restart
docker-compose restart ${SERVICES}
elif [ "${1}" = "status" ]
then
docker-compose ps
Expand Down
2 changes: 0 additions & 2 deletions src/tiler/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ claudia.json
#Ignore coverage data from jest
/coverage/

# Ignore generated xml files
src/config/*.xml
9 changes: 4 additions & 5 deletions src/tiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
],
"scripts": {
"build-all-xml": "./scripts/build-all-xml.sh src/config src/config",
"deploy": "yarn compile && claudia update --no-optional-dependencies ${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} ${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} ${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} ${LAMBDA_SUBNETS:+--subnet-ids ${LAMBDA_SUBNETS}}",
"deploy-new": "yarn compile && claudia create --no-optional-dependencies --api-module src/api --name ${PROJECT_NAME} --region ${LAMBDA_REGION} ${LAMBDA_ROLE:+--role ${LAMBDA_ROLE}} ${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} ${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} ${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} ${LAMBDA_SUBNETS:+--subnet-ids ${LAMBDA_SUBNETS}} && yarn parse-id",
"deploy": "./scripts/deploy",
"deploy-new": "./scripts/deploy-new",
"destroy": "claudia destroy",
"dev": "nodemon -e js,mss,json,mml,mss --ignore '*.temp.mml' --exec yarn local",
"lint": "eslint src",
"local": "yarn compile && node --inspect=0.0.0.0:9229 -- node_modules/claudia-local-api/bin/claudia-local-api --abbrev 300 --api-module src/api | bunyan -o short",
"local": "node --inspect=0.0.0.0:9229 -- node_modules/claudia-local-api/bin/claudia-local-api --abbrev 300 --api-module src/api | bunyan -o short",
"parse-id": "jq -r '.api.id' claudia.json > .api-id",
"test": "eslint src && jest --coverage",
"compile": "yarn build-all-xml"
"test": "eslint src && jest --coverage"
},
"devDependencies": {
"bunyan": "^1.8.12",
Expand Down
23 changes: 5 additions & 18 deletions src/tiler/scripts/build-xml.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
#!/usr/bin/env bash

# This script is never meant to be called directly by the user.
# It should only be called by other scripts that pass MML strings
# in to it, so that different environments can have access to the
# version of carto installed on the docker container.
# This script used to be more complicated, involving filling in environment variables.
# Now they stay variables until later in the process, but it's easier to keep this as a
# script than to put the command inline in the places where it's used, especially since
# it seems possible that it could change again.

function main() {
tempFile="${1%%.*}.temp.mml"

# fill in environment variables
node scripts/template-vars.js "${1}" > ${tempFile}

# compile with carto
carto ${tempFile}

# clean up
rm ${tempFile}
}

main "${1}" "${2}"
carto "${1}"
8 changes: 8 additions & 0 deletions src/tiler/scripts/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

yarn claudia update --no-optional-dependencies \
${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} \
${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} \
${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} \
${LAMBDA_SUBNETS:+--subnet-ids ${LAMBDA_SUBNETS}} \
--set-env TILEGARDEN_DB_HOST=${TILEGARDEN_DB_HOST},TILEGARDEN_DB_NAME=${TILEGARDEN_DB_NAME},TILEGARDEN_DB_PASSWORD=${TILEGARDEN_DB_PASSWORD},TILEGARDEN_DB_PORT=${TILEGARDEN_DB_PORT},TILEGARDEN_DB_USER=${TILEGARDEN_DB_USER}
11 changes: 11 additions & 0 deletions src/tiler/scripts/deploy-new
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

yarn claudia create --no-optional-dependencies --api-module src/api \
--name ${PROJECT_NAME} --region ${LAMBDA_REGION} \
${LAMBDA_ROLE:+--role ${LAMBDA_ROLE}} \
${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} \
${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} \
${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} \
${LAMBDA_SUBNETS:+--subnet-ids ${LAMBDA_SUBNETS}} \
--set-env TILEGARDEN_DB_HOST=${TILEGARDEN_DB_HOST},TILEGARDEN_DB_NAME=${TILEGARDEN_DB_NAME},TILEGARDEN_DB_PASSWORD=${TILEGARDEN_DB_PASSWORD},TILEGARDEN_DB_PORT=${TILEGARDEN_DB_PORT},TILEGARDEN_DB_USER=${TILEGARDEN_DB_USER} \
&& yarn parse-id
26 changes: 0 additions & 26 deletions src/tiler/scripts/template-vars.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Layer:
geometry: polygon
srs: "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs"
Datasource:
host: ${TILEGARDEN_HOST}
dbname: ${TILEGARDEN_DB}
user: ${TILEGARDEN_USER}
password: ${TILEGARDEN_PASSWORD}
host: ${TILEGARDEN_DB_HOST}
port: ${TILEGARDEN_DB_PORT}
dbname: ${TILEGARDEN_DB_NAME}
user: ${TILEGARDEN_DB_USER}
password: ${TILEGARDEN_DB_PASSWORD}
type: "postgis"
table: "street_centerline"
key_field: ""
Expand All @@ -25,10 +26,11 @@ Layer:
geometry: polygon
srs: "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs"
Datasource:
host: ${TILEGARDEN_HOST}
dbname: ${TILEGARDEN_DB}
user: ${TILEGARDEN_USER}
password: ${TILEGARDEN_PASSWORD}
host: ${TILEGARDEN_DB_HOST}
port: ${TILEGARDEN_DB_PORT}
dbname: ${TILEGARDEN_DB_NAME}
user: ${TILEGARDEN_DB_USER}
password: ${TILEGARDEN_DB_PASSWORD}
type: "postgis"
table: "pwd_parcels"
key_field: ""
Expand All @@ -38,10 +40,11 @@ Layer:
geometry: polygon
srs: "+proj=longlat +datum=WGS84 +no_defs"
Datasource:
host: ${TILEGARDEN_HOST}
dbname: ${TILEGARDEN_DB}
user: ${TILEGARDEN_USER}
password: ${TILEGARDEN_PASSWORD}
host: ${TILEGARDEN_DB_HOST}
port: ${TILEGARDEN_DB_PORT}
dbname: ${TILEGARDEN_DB_NAME}
user: ${TILEGARDEN_DB_USER}
password: ${TILEGARDEN_DB_PASSWORD}
type: "postgis"
table: "inlets"
key_field: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Layer:
geometry: polygon
srs: "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs"
Datasource:
host: ${TILEGARDEN_HOST}
dbname: ${TILEGARDEN_DB}
user: ${TILEGARDEN_USER}
password: ${TILEGARDEN_PASSWORD}
host: ${TILEGARDEN_DB_HOST}
port: ${TILEGARDEN_DB_PORT}
dbname: ${TILEGARDEN_DB_NAME}
user: ${TILEGARDEN_DB_USER}
password: ${TILEGARDEN_DB_PASSWORD}
type: "postgis"
table: "street_centerline"
key_field: ""
Expand All @@ -25,10 +26,11 @@ Layer:
geometry: polygon
srs: "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs"
Datasource:
host: ${TILEGARDEN_HOST}
dbname: ${TILEGARDEN_DB}
user: ${TILEGARDEN_USER}
password: ${TILEGARDEN_PASSWORD}
host: ${TILEGARDEN_DB_HOST}
port: ${TILEGARDEN_DB_PORT}
dbname: ${TILEGARDEN_DB_NAME}
user: ${TILEGARDEN_DB_USER}
password: ${TILEGARDEN_DB_PASSWORD}
type: "postgis"
table: "pwd_parcels"
key_field: ""
Expand All @@ -38,10 +40,11 @@ Layer:
geometry: polygon
srs: "+proj=longlat +datum=WGS84 +no_defs"
Datasource:
host: ${TILEGARDEN_HOST}
dbname: ${TILEGARDEN_DB}
user: ${TILEGARDEN_USER}
password: ${TILEGARDEN_PASSWORD}
host: ${TILEGARDEN_DB_HOST}
port: ${TILEGARDEN_DB_PORT}
dbname: ${TILEGARDEN_DB_NAME}
user: ${TILEGARDEN_DB_USER}
password: ${TILEGARDEN_DB_PASSWORD}
type: "postgis"
table: "inlets"
key_field: ""
Expand Down
Loading