From 965e2ede8321e3db2d9c80faae254c21d3bbe699 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Thu, 30 Sep 2021 20:10:51 +1000 Subject: [PATCH] Deployment tooling --- client.js | 2 +- config/default.json | 18 +++++++------- config/production.json | 56 ++++++++++++++++++++++++++++++++++++++++++ config/test.json | 20 --------------- docker-compose.yml | 26 ++++++++++++++++++++ nginx-conf/nginx.conf | 30 ++++++++++++++++++++++ package.json | 2 +- 7 files changed, 123 insertions(+), 31 deletions(-) create mode 100644 config/production.json delete mode 100644 config/test.json create mode 100644 docker-compose.yml create mode 100644 nginx-conf/nginx.conf diff --git a/client.js b/client.js index 0b7c287..21ed0cc 100644 --- a/client.js +++ b/client.js @@ -57,7 +57,7 @@ export async function getOSMAerodromeData (areaName) { cache.set(areaName, data, 86400); } }, - { overpassUrl: config.get('data.osm.overpassUrl') } + { overpassUrl: config.get('data.osm.overpassUrl'), userAgent: `${config.get('app.name')}/${config.get('app.version')}` } ); }catch(err){ diff --git a/config/default.json b/config/default.json index 902b77f..e447e89 100644 --- a/config/default.json +++ b/config/default.json @@ -22,19 +22,19 @@ "sectors": { "standard": [ "BN-ARA_CTR", - "BN-DOS_CTR", "BN-ISA_CTR", - "BN-MDE_CTR", - "BN-TBP_CTR", + "BN-KEN_CTR", + "BN-INL_CTR", + "BN-ARM_CTR", "BN-TRT_CTR", "ML-ASP_CTR", - "ML-BKE_CTR", - "ML-ESP_CTR", - "ML-ORE_CTR", - "ML-SNO_CTR", + "ML-ARM_CTR", + "ML-OLW_CTR", + "ML-PIY_CTR", "ML-TBD_CTR", "ML-TAS_CTR", - "ML-WOL_CTR" + "ML-ELW_CTR", + "ML-BIK_CTR" ] } }, @@ -50,7 +50,7 @@ "coloursUrl": "https://raw.githubusercontent.com/vatSys/australia-dataset/master/Colours.xml" }, "osm": { - "overpassUrl": "https://localhost/api/interpreter", + "overpassUrl": "https://lz4.overpass-api.de/api/interpreter", "aerodromesArea": "New South Wales" } } diff --git a/config/production.json b/config/production.json new file mode 100644 index 0000000..24a2dba --- /dev/null +++ b/config/production.json @@ -0,0 +1,56 @@ +{ + "app": { + "name": "vatsim-map", + "version": "0.0.1", + "url": "https://github.com/Kahn/vatsim-map", + "log_level": 30, + "http": { + "host": "0.0.0.0", + "port": 8080 + } + }, + "map": { + "firs" : [ + "AGGG", + "ANAU", + "AYPM", + "BRISBANE_FIR", + "MELBOURNE_FIR", + "NFFF-A", + "NFFF-B" + ], + "sectors": { + "standard": [ + "BN-ARA_CTR", + "BN-ISA_CTR", + "BN-MDE_CTR", + "BN-TBP_CTR", + "BN-TRT_CTR", + "ML-ASP_CTR", + "ML-BKE_CTR", + "ML-ESP_CTR", + "ML-ORE_CTR", + "ML-SNO_CTR", + "ML-TBD_CTR", + "ML-TAS_CTR", + "ML-WOL_CTR" + ] + } + }, + "data": { + "vatsim": { + "dataUrl": "https://data.vatsim.net/v3/vatsim-data.json" + }, + "vatsys": { + "fir_boundariesUrl": "https://raw.githubusercontent.com/vatSys/australia-dataset/master/Maps/FIR_BOUNDARIES.xml", + "volumesUrl": "https://raw.githubusercontent.com/vatSys/australia-dataset/master/Volumes.xml", + "sectorsUrl": "https://raw.githubusercontent.com/vatSys/australia-dataset/master/Sectors.xml", + "coastlineUrl": "https://raw.githubusercontent.com/vatSys/australia-dataset/master/Maps/COAST_ALL.xml", + "coloursUrl": "https://raw.githubusercontent.com/vatSys/australia-dataset/master/Colours.xml" + }, + "osm": { + "overpassUrl": "https://lz4.overpass-api.de/api/interpreter", + "aerodromesArea": "New South Wales" + } + } +} \ No newline at end of file diff --git a/config/test.json b/config/test.json deleted file mode 100644 index 1cb197f..0000000 --- a/config/test.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "urls": { - "vatsim": { - "data": "https://data.vatsim.net/v3/vatsim-data.json" - }, - "vatsys": { - "fir_boundaries": "https://raw.githubusercontent.com/vatSys/australia-dataset/master/Maps/FIR_BOUNDARIES.xml" - } - }, - "app": { - "name": "vatsim-map", - "version": "0.0.1", - "url": "https://github.com/Kahn/vatsim-map", - "log_level": 30, - "http": { - "host": "0.0.0.0", - "port": 8080 - } - } -} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c258057 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3.9' +services: + express: + container_name: express + build: + context: . + dockerfile: Dockerfile + command: node server.js + volumes: + - .:/usr/app/ + - /usr/app/node_modules + ports: + - "8080:8080" + restart: unless-stopped + environment: + - NODE_ENV=production + webserver: + image: nginx:mainline-alpine + container_name: webserver + restart: unless-stopped + ports: + - "80:80" + volumes: + - ./nginx-conf/nginx.conf:/etc/nginx/nginx.conf + depends_on: + - express \ No newline at end of file diff --git a/nginx-conf/nginx.conf b/nginx-conf/nginx.conf new file mode 100644 index 0000000..9e4628b --- /dev/null +++ b/nginx-conf/nginx.conf @@ -0,0 +1,30 @@ +events { + worker_connections 1024; +} +http { + proxy_cache_path /tmp/nginx-cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g; + server { + listen 80; + listen [::]:80; + root /var/www/html; + index index.html index.htm; + location / { + proxy_pass http://express:8080; + proxy_set_header Host $host; + proxy_buffering on; + proxy_cache STATIC; + proxy_cache_valid 200 1h; + proxy_cache_use_stale error timeout invalid_header updating + http_500 http_502 http_503 http_504; + } + location /v1/ { + proxy_pass http://express:8080; + proxy_set_header Host $host; + proxy_buffering on; + proxy_cache STATIC; + proxy_cache_valid 200 15s; + proxy_cache_use_stale error timeout invalid_header updating + http_500 http_502 http_503 http_504; + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 8664f5f..b4c22f9 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "express": "^4.17.1", "node-cache": "^5.1.2", "node-fetch": "^2.6.1", - "query-overpass": "^1.5.5", + "query-overpass": "https://github.com/Kahn/query-overpass.git", "rgb2hex": "^0.2.5", "xml-js": "^1.6.11" },