Skip to content

Instantly share code, notes, and snippets.

@mtuchi
Forked from sdrew/Procfile
Created May 3, 2019 11:53
Show Gist options
  • Save mtuchi/f81f04df43e2d97fb56c2a6eda1844ac to your computer and use it in GitHub Desktop.
Save mtuchi/f81f04df43e2d97fb56c2a6eda1844ac to your computer and use it in GitHub Desktop.
Laravel configs for Heroku/Dokku
{
"name": "laravel-test",
"description": "A barebones Laravel 5 app on Dokku/Heroku.",
"keywords": [
"laravel",
"dokku",
"heroku"
],
"scripts": {
"dokku": {
"predeploy": ".dokku/predeploy.sh",
"postdeploy": ".dokku/postdeploy.sh"
}
}
}
https://github.com/heroku/heroku-buildpack-php
<?php
if (getenv('DATABASE_URL')) {
$url = parse_url(env("DATABASE_URL"));
// Laravel's env() uses getenv(), not $_ENV[]
putenv('DB_CONNECTION=' . ($url['scheme'] == 'postgres' ? 'pgsql' : $url['scheme']));
putenv("DB_HOST={$url['host']}");
putenv("DB_PORT={$url['port']}");
putenv("DB_USERNAME={$url['user']}");
putenv("DB_PASSWORD={$url['pass']}");
putenv('DB_DATABASE=' . substr($url['path'], 1)); // Remove leading slash from path
}
?>
#!/bin/bash
set -eo pipefail;
# Create storage paths if missing in persistent storage.
mkdir -p storage/app/public
mkdir -p storage/framework/{cache,sessions,testing,views}
mkdir -p storage/logs
# Link already created in predeploy.
# Run for a confirmation message that it was created successfully.
php artisan storage:link
#!/bin/bash
set -eo pipefail;
# Remove old symlink in public/storage if exists
[[ -r public/storage ]] && rm public/storage
# Create storage paths if missing in container.
# NOTE: Persistent storage still not mounted in predeploy step.
mkdir -p storage/app/public
mkdir -p storage/framework/{cache,sessions,testing,views}
mkdir -p storage/logs
# Create storage symlink in predeploy linking to container, not persistent storage.
# Link target will be substituted when persistent storage is mounted.
php artisan storage:link
web: vendor/bin/heroku-php-apache2 public/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment