-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge entire oam-uploader-api-repo with history
Just resolves conflicts
- Loading branch information
Showing
46 changed files
with
2,280 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[stage] | ||
host 52.11.15.48 | ||
user ubuntu | ||
repo https://github.com/hotosm/oam-uploader-api.git | ||
path /home/ubuntu/oam-uploader-api | ||
ref origin/develop | ||
needs_tty yes | ||
post-deploy .build_scripts/post-deploy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
# This script runs the docker container for this application, by: | ||
# - passing in the environment variables defined in local.env, if it exists | ||
# - overriding the above with any relevant variables in the current environment | ||
# (see config.js) | ||
# - exposing the $PORT (default: 3000), on which the app listens | ||
# - setting the container to use the host OS's networking stack (better | ||
# performance, worse isolation) | ||
# - mounting the current directory--which should be the project root--as | ||
# `/local`. | ||
# | ||
# The intent of the last item is that the app can be setup (npm install) and | ||
# run directly from its location on the host OS, but using the container as its | ||
# environment to make dependency management trivial. | ||
|
||
if [ -f local.env ] ; then | ||
ENVFILE="--env-file local.env" | ||
else | ||
ENVFILE="" | ||
fi | ||
|
||
if [[ -t 0 || -p /dev/stdin ]] ; then | ||
echo "Running in tty mode." | ||
MODE=-it | ||
else | ||
MODE= | ||
fi | ||
|
||
PORT=${PORT:-3000} | ||
|
||
ARGS_LENGTH=$(($#-1)) | ||
ARGS=${@:1:$ARGS_LENGTH} | ||
COMMAND=${@:$((ARGS_LENGTH+1)):1} | ||
|
||
exec docker run $MODE --rm \ | ||
-p $PORT \ | ||
$ENVFILE \ | ||
-e OAM_TEST \ | ||
-e PORT \ | ||
-e HOST \ | ||
-e OIN_BUCKET \ | ||
-e DBURI \ | ||
-e DBURI_TEST \ | ||
-e MAX_WORKERS \ | ||
-e ADMIN_PASSWORD \ | ||
-e ADMIN_USERNAME \ | ||
-e AWS_SECRET_KEY_ID \ | ||
-e AWS_SECRET_ACCESS_KEY \ | ||
-e AWS_REGION \ | ||
--net=\"host\" \ | ||
-v $(pwd):/app \ | ||
$ARGS \ | ||
oam-uploader-api $COMMAND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# Run the server inside docker. | ||
|
||
npm start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# Run the tests inside docker. | ||
|
||
npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
.build_scripts/docker/run.sh /install.sh | ||
sudo stop oam-uploader-api | ||
sudo start oam-uploader-api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
var readline = require('readline'); | ||
var MongoClient = require('mongodb').MongoClient; | ||
var dbUri = require('../config').dbUri; | ||
|
||
var rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
|
||
rl.question("Type 'yes' if you really want to clear the database: ", function (answer) { | ||
if (answer === 'yes') { | ||
console.log('Okay, doing it!'); | ||
MongoClient.connect(dbUri, function (err, connection) { | ||
if (err) throw err; | ||
console.log('Connected to db.'); | ||
console.log('Dropping workers'); | ||
connection.dropCollection('workers') | ||
.then(function () { | ||
console.log('Dropping uploads'); | ||
return connection.dropCollection('uploads'); | ||
}) | ||
.then(function () { | ||
console.log('Dropping tokens'); | ||
return connection.dropCollection('tokens'); | ||
}) | ||
.then(function () { | ||
console.log('Dropping images'); | ||
return connection.dropCollection('images'); | ||
}) | ||
.then(function () { | ||
console.log('Done.'); | ||
connection.close(); | ||
}) | ||
.catch(function (err) { | ||
console.error(err); | ||
connection.close(); | ||
}); | ||
}); | ||
} else { | ||
console.log('Abort! Whew!'); | ||
} | ||
rl.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!upstart | ||
description "oam-uploader-api server" | ||
author "anand" | ||
|
||
start on filesystem and started docker | ||
stop on runlevel [!2345] | ||
|
||
env USER=ubuntu | ||
env OAM_UPLOADER_DIR=/home/ubuntu/oam-uploader-api/current | ||
|
||
script | ||
echo $$ > /var/run/oam-uploader-api.pid | ||
cd $OAM_UPLOADER_DIR | ||
exec sudo -u $USER $OAM_UPLOADER_DIR/.build_scripts/docker/run.sh --name=oam-uploader-api /start.sh >> /var/log/oam-uploader-api.sys.log 2>&1 | ||
end script | ||
|
||
pre-start script | ||
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/oam-uploader-api.sys.log | ||
end script | ||
|
||
pre-stop script | ||
rm /var/run/oam-uploader-api.pid | ||
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/oam-uploader-api.sys.log | ||
docker stop oam-uploader-api | ||
end script | ||
|
||
post-stop script | ||
rm /var/run/oam-uploader-api.pid | ||
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopped" >> /var/log/oam-uploader-api.sys.log | ||
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,7 @@ node_modules | |
newrelic_agent.log | ||
npm-debug.log | ||
.travis.yml | ||
.build_scripts | ||
.build_scripts | ||
.env | ||
.git | ||
local.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ tmp | |
scratch.js | ||
docs | ||
local.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.5.0 | ||
4.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
brew 'mongodb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,26 @@ The worker process runs on a schedule (every 5 minutes by default) and checks fo | |
- `SECRET_TOKEN` - The token used for post requests to `/tms` endpoint | ||
- `NEW_RELIC_LICENSE_KEY` - Your New Relic API monitoring license key | ||
|
||
- `NODE_ENV` - Node environment. When in production should be set to `production`, otherwise can be ignored. | ||
- `PORT` - The port to listen on (Default to 4000). | ||
- `HOST` - The hostname or ip address (Default to 0.0.0.0). | ||
- `COOKIE_PASSWORD` - Password used for cookie encoding. Should be at least 32 characters long. IMPORTANT to change the default one for production. | ||
- `AWS_ACCESS_KEY_ID` - AWS secret key id for reading `OIN_BUCKET`. | ||
- `AWS_SECRET_ACCESS_KEY` - AWS secret access key for reading `OIN_BUCKET`. | ||
- `AWS_REGION` - AWS region of `OIN_BUCKET` (Default to us-west-2). | ||
- `SENDGRID_API_KEY` - Sendgrid API key, for sending notification emails. | ||
- `SENDGRID_FROM` - Email address from which to send notification emails (Default to [email protected]). | ||
- `OIN_BUCKET` - The OIN bucket that will receive the uploads (Default to oam-uploader). | ||
- `DBURI` - MongoDB connection url (Default to mongodb://localhost/oam-uploader) | ||
- `DBURI_TEST` - MongoDB connection url for tests. Will be loaded when `NODE_ENV` is `test`. It's not needed for production. (Default to mongodb://localhost/oam-uploader-test) | ||
- `ADMIN_USERNAME` - Username to access the [Token Management](https://github.com/hotosm/oam-uploader-admin) panel. | ||
- `ADMIN_PASSWORD` - Password to access the [Token Management](https://github.com/hotosm/oam-uploader-admin) panel. | ||
- `GDRIVE_KEY` - Google Api key. Needed to use the upload from google drive functionality. | ||
- `GDAL_TRANSLATE_BIN` - Full path to the gdal bin (Default to /usr/bin/gdal_translate) | ||
- `MAX_WORKERS` - Max number of workers used to process the uploads (Default to 1) | ||
- `NEW_RELIC_LICENSE_KEY` - New relic license key. | ||
- `TILER_BASE_URL` - Base URL for dynamic TMS/WMTS endpoints. Defaults to `http://tiles.openaerialmap.org`. | ||
|
||
If you are running a local OAM bucket, here are additional environment variables you can configure (more information in the Docker > Local Indexing section) | ||
- `HOST_PREFIX`: - Used by the localoam service to construct URIs that point to the images (default: `http://localoam`) | ||
- `LOCAL_OAM_BUCKET`: - Used by the localoam service as the location of the HTTP server (default is a docker context service name: `http://localoam:4999`) | ||
|
Oops, something went wrong.