Skip to content

Commit

Permalink
Heroku button
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewiscowles1986 committed Jan 28, 2020
1 parent 70c0c5d commit d4e2129
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ GITHUB_CLIENT_SECRET=

TWITTER_CLIENT_ID=
TWITTER_CLIENT_SECRET=

REDIS_URL=tcp://127.0.0.1:6379
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: vendor/bin/heroku-php-apache2 public/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
IndieLogin
==========

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

IndieLogin enables users to sign in with their domain name by linking their domain name to existing authentication providers.
101 changes: 101 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"name": "Indielogin",
"description": "Deploy Indielogin to heroku",
"repository": "https://github.com/aaronpk/indielogin.com",
"logo": "https://github.com/aaronpk/indielogin.com/raw/master/public/icons/android-chrome-512x512.png",
"website": "https://indielogin.com",
"keywords": ["indielogin", "nginx", "php", "indieauth"],
"addons": [
"heroku-redis",
{
"plan": "cleardb:ignite"
}
],
"env": {
"BASE_URL": {
"description": "The base URL of your application including port",
"value": "",
"required": false
},
"APP_NAME": {
"description": "The application name",
"value": "IndieLogin.com",
"required": false
},
"DB_HOST": {
"description": "MySQL database Host (include port if necesarry)",
"value": "",
"required": false
},
"DB_USER": {
"description": "MySQL database username",
"value": "",
"required": false
},
"DB_PASS": {
"description": "MySQL database password",
"value": "",
"required": false
},
"DB_NAME": {
"description": "MySQL database name",
"value": "",
"required": false
},
"HTTP_USER_AGENT": {
"description": "User Agent",
"value": "Indielogin (heroku)"
},
"GITHUB_CLIENT_ID": {
"description": "Client ID for GitHub API requests",
"value": "",
"required": false
},
"GITHUB_CLIENT_SECRET": {
"description": "Client Secret for GitHub API requests",
"value": "",
"required": false
},
"TWITTER_CLIENT_ID": {
"description": "Client ID for Twitter API requests",
"value": "",
"required": false
},
"TWITTER_SECRET_SECRET": {
"description": "Client Secret for Twitter API requests",
"value": "",
"required": false
},
"MAILGUN_KEY": {
"description": "Mailgun Key for sending emails",
"value": "",
"required": false
},
"MAILGUN_DOMAIN": {
"description": "Mailgun Domain to send emails from",
"value": "",
"required": false
},
"MAILGUN_FROM": {
"description": "Mailgun From email address",
"value": "",
"required": false
},
"PGP_VERIFICATION_API": {
"description": "PGP Verification API URL",
"value": "",
"required": false
}
},
"formation": {
"web": {
"quantity": 1,
"size": "free"
}
},
"buildpacks": [
{
"url": "heroku/php"
}
]
}
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"michelf/php-markdown": "^1.8",
"vlucas/phpdotenv": "^4.1"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
},
"autoload": {
"psr-4": {
"App\\": "app/"
Expand Down
49 changes: 47 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions heroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
docker:
web: Dockerfile
24 changes: 20 additions & 4 deletions lib/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,29 @@
}

function initdb() {
if(!empty(getenv('DB_HOST'))) {
ORM::configure('mysql:host=' . getenv('DB_HOST') . ';dbname=' . getenv('DB_NAME'));
ORM::configure('username', getenv('DB_USER'));
ORM::configure('password', getenv('DB_PASS'));
$db_env = array_filter(
[
getenv('DATABASE_URL'),
getenv('JAWSDB'),
getenv('CLEARDB_DATABASE_URL')
], function($val) { return !empty($val); }
);
if(!empty($db_env)) {
$mysql = parse_url(current($db_env));
setupDB($mysql['host'], $mysql['user'], $mysql['pass'], basename($mysql['path']), @$mysql['port']);
} elseif(!empty(getenv('DB_HOST'))) {
setupDB(getenv('DB_HOST'), getenv('DB_USER'), getenv('DB_PASS'), getenv('DB_NAME'), getenv('DB_PORT'));
}
}

function setupDB($host, $user, $pass, $dbname, $port='') {
$portstr = strlen($port) > 0 ? ":${port}" : '';
ORM::configure("mysql:host=${host};dbname=${dbname}");
ORM::configure('username', $user);
ORM::configure('password', $pass);
define('DB_SETUP', true);
}

function make_logger($channel) {
$log = new Logger($channel);
$log->pushHandler(new StreamHandler(dirname(__FILE__).'/../logs/app.log', Logger::DEBUG));
Expand Down
3 changes: 3 additions & 0 deletions public/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
2 changes: 1 addition & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$templates = new League\Plates\Engine(dirname(__FILE__).'/../views');

// Check for existence of config variables, and show an error page if not set
if(empty(getenv('APP_NAME')) || empty(getenv('DB_HOST'))) {
if(empty(getenv('APP_NAME')) || !defined('DB_SETUP')) {
echo view('setup-error', [
'title' => 'Setup Error',
]);
Expand Down

0 comments on commit d4e2129

Please sign in to comment.