Skip to content

Instantly share code, notes, and snippets.

@tebajanga
Forked from sdrew/Procfile
Created October 19, 2019 21:48
Show Gist options
  • Save tebajanga/ed5d4372c7380dea6c0f591e48470f8e to your computer and use it in GitHub Desktop.
Save tebajanga/ed5d4372c7380dea6c0f591e48470f8e 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