beginning heroku documentation
authorBryan Bonvallet <btbonval@gmail.com>
Thu, 15 May 2014 03:07:48 +0000 (23:07 -0400)
committerBryan Bonvallet <btbonval@gmail.com>
Thu, 15 May 2014 03:07:48 +0000 (23:07 -0400)
.env.example
README.heroku [new file with mode: 0644]
export_env_to_heroku.py [new file with mode: 0644]

index 294407a1ebd11c875eef55972ab2e483de0ddc4b..78d7bf24a719f801b1a2bfef850e2f2047b715da 100644 (file)
@@ -1,19 +1,24 @@
-DATABASE_URL=
-GOOGLE_CLIENT_SECRETS=
-GOOGLE_USER=
-GOOGLE_SERVICE_KEY_BASE64=
-FILEPICKER_API_KEY=
-FILEPCIKER_SECRET=
-INDEXDEN_PRIVATE_URL=
-INDEXDEN_INDEX=
-DEFAULT_FILE_STORAGE=
-AWS_ACCESS_KEY_ID=
-AWS_SECRET_ACCESS_KEY=
-AWS_STORAGE_BUCKET_NAME=
-CLOUDFRONT_URL=
-CLOUDFRONT_DOMAIN=
-TWITTER_CONSUMER_KEY=
-TWITTER_CONSUMER_SECRET=
-TWITTER_ACCESS_TOKEN_KEY=
-TWITTER_ACCESS_TOKEN_SECRET=
-MTURK_HOST=
+DATABASE_URL='postgres://<user>:<password>@<host>:<port>/<database>'
+
+GOOGLE_CLIENT_SECRETS='{"web": {"json": "goes here"} }'
+GOOGLE_USER='GoogleApps@Email.Address'
+GOOGLE_SERVICE_KEY_BASE64='Base64EncodedP12FileContentsGoHere'
+
+FILEPICKER_API_KEY='NonSeNsEAscIi'
+FILEPICKER_SECRET='MORENONSENSEASCII'
+
+INDEXDEN_PRIVATE_URL='https://:<password>@<something>.api.indexden.com'
+INDEXDEN_INDEX='index_name'
+
+DEFAULT_FILE_STORAGE='storages.backends.s3boto.S3BotoStorage'
+AWS_ACCESS_KEY_ID='ASCIINONSENSE'
+AWS_SECRET_ACCESS_KEY='AlphaNumerics+OtherCharacters'
+AWS_STORAGE_BUCKET_NAME='bucket_name'
+CLOUDFRONT_URL=''
+CLOUDFRONT_DOMAIN=''
+MTURK_HOST=''
+
+TWITTER_CONSUMER_KEY=''
+TWITTER_CONSUMER_SECRET=''
+TWITTER_ACCESS_TOKEN_KEY=''
+TWITTER_ACCESS_TOKEN_SECRET=''
diff --git a/README.heroku b/README.heroku
new file mode 100644 (file)
index 0000000..562cf9e
--- /dev/null
@@ -0,0 +1,18 @@
+Checkout the karmanotes repository locally.
+
+Create Heroku app from either the web interface or the CLI. See Heroku documentation for more information.
+
+From the settings page for the Heroku app, find the Git URL and copy it.
+
+Install the Heroku CLI. Make sure to configure the Heroku CLI tool with `heroku login`.
+
+In the karmanotes repository:
+`git remote add my-heroku-dev git@heroku.com:<your-project-name>.git`
+
+Create a Heroku database either from the web interface or the CLI. Look for the Dev Plan (its free). Once created, keep track of its connection settings for the configuration step.
+
+Configure the application by copying `${project_root}/.env.example` to `${project_root}/.env` and edit it appropriately for all external dependencies.
+
+Push the configuration to Heroku by running the handy script. `python export_env_to_heroku.py`
+
+Push the app to Heroku with git. `git push my-heroku-dev master`
diff --git a/export_env_to_heroku.py b/export_env_to_heroku.py
new file mode 100644 (file)
index 0000000..2f91065
--- /dev/null
@@ -0,0 +1,19 @@
+import subprocess
+
+def export_env(filename='.env'):
+    data=['heroku', 'config:set']
+    with open(filename, 'r') as config:
+        for line in config.readlines():
+            # ignore whitespace padding
+            line.strip()
+            tmp = line.split('=')
+            # further ignore whitespace padding that was around the =
+            tmp = map(str.strip, tmp)
+            # check for nonempty variable and content
+            if len(tmp) == 2 and len(tmp[0]) and len(tmp[1]):
+                data.append('{0}={1}'.format(*tmp))
+    return subprocess.check_call(data)
+
+if __name__ == '__main__':
+    import sys
+    sys.exit(export_env('.env.example'))