Git Product home page Git Product logo

simple-odk-digidem's Introduction

Simple-ODK Server

This is a simple-odk server configured for Digital Democracy production use with our partners.

Install

git clone https://github.com/digidem/simple-odk-digidem
cd simple-odk-digidem
npm install

Setup

We use dokku for deployment. See digidem-server for more details of our server provisioning and configuration.

To deploy a new version of Simple ODK, first ensure you have our production server configured as a github remote:

git remote -v
# Should output:
# dokku [email protected]:simple-odk (fetch)
# dokku [email protected]:simple-odk (push)
# origin  [email protected]:digidem/simple-odk-digidem.git (fetch)
# origin  [email protected]:digidem/simple-odk-digidem.git (push)

If dokku remote is missing, add it with:

git remote add dokku [email protected]:simple-odk

Install dokku-toolbelt:

npm install -g dokku-toolbelt

Config

Simple-ODK uses environment variables for configuration of API keys. The following keys need to be set in order for everything to work:

  • S3_BUCKET: This is the default S3 bucket where media will be stored.
  • S3_KEY: Your S3 Access Key ID. The S3 bucket should have s3:PutObject and s3:PutObjectAcl permission for the user associated with this key.
  • S3_SECRET: S3 Secret Key associated with the Key ID.
  • NEWRELIC_KEY: A New Relic Rest API Key for sending application monitoring data to New Relic.

By default all media is uploaded to S3_BUCKET and the form upload is defined by the URL. E.g. http://simple-odk-server.com/gh/digidem/sample-monitoring-data/submission will post a form to the github repo digidem/sample-monitoring-data. We can set up aliases and virtual hosts (deprecated) to avoid long, complex URLs and allow the storage backend to be changed without updating the URLs on every phone with ODK Collect.

Set environment variables with dt config:set S3_BUCKET=my_bucket

alias-config.json

Configures aliases for specific configurations in the format:

{
  "github_alias": {
    "formStore": "github",
    "user": "github_owner_of_repo",
    "repo": "github_repo_name",
    "s3bucket": "s3_bucket_name_for_media_uploads"
  },
  "a_different_alias_name": {
    "formStore": "gist",
    "gist_id": "id_of_gist_to_store_forms",
    "s3bucket": "s3_bucket_name_for_media_uploads"
  },
  "firebase_alias": {
    "formStore": "firebase",
    "appname": "firebase_app_name"
  }
}

This would mean that any submission to https://simple-odk-server.com/github_alias/submission would be stored in the github repo github_owner_of_repo/github_repo_name.

vhost-config.json

Same as alias-config.json above but the keys must be fully qualified domain names, the domains should point to the simple-odk server address, and domains need to be added to dokku with dt domains:add simple-odk my-domain.com.

nginx.conf

We customize some nginx settings with ./nginx.conf.d/nginx.conf. This is where we set the maximum upload size, the buffer settings, and timeouts. See the comments for more details. If we are getting timeouts over slow connections we can increase the values here and push a new version to dokku.

Deployment

Once the environment variables are set we can deploy a new version of simple-odk with:

git push dokku master

SSL Certificates

In order for ODK Collect to make a secure connection to our server we need to have valid SSL certificates for each domain. This is all managed by the amazing dokku-letsencrypt plugin, which is installed by default by our server config script.

  1. Once all the domains are configured for simple-odk, remove the default sub-domain e.g. dt domains:remove simple-odk.apps.digital-democracy.org.
  2. Make sure that the DNS is configured for all domains so that they point to this server.
  3. Run dt letsencrypt and sit back, certificates will be downloaded and configured.

LetsEncrypt certificates are only valid for 90 days, so we set up a cron job on the server to auto-renew all certificates using these instructions.

simple-odk-digidem's People

Contributors

gmaclennan avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

simple-odk-digidem's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.