Skip to content

Commit

Permalink
Make App compatible to be deployed to Heroku (#350)
Browse files Browse the repository at this point in the history
* Add Procfile

* Update TrustProxies

* Update Loggin

* Add Sessions Table

* Add league/flysystem-aws-s3-v3 as dependency

* Add screeenly.filesystem_disk config

* Use new config in code

* Fix doesScreenshotExist

* Declare S3 as public

* Handle doesScreenshotExist differently per disk

* Update screeenly:cleanup

* Create app.json

* Add Deploy to Heroku Button

* Update app.json

* Add heroku-scheduler addon

* Use Postgres 13

* Update README
  • Loading branch information
stefanzweifel committed Feb 12, 2021
1 parent 52da991 commit 04af491
Show file tree
Hide file tree
Showing 19 changed files with 348 additions and 34 deletions.
1 change: 1 addition & 0 deletions .env.example
Expand Up @@ -47,6 +47,7 @@ GITHUB_REDIRECT_URL=REDIRECT_URL
# Disable Chrome's Sandbox feature
# More information: https://github.com/stefanzweifel/screeenly/issues/174#issuecomment-423438612
SCREEENLY_DISABLE_SANDBOX=false
SCREEENLY_DISK=public


## Misc Configuration
Expand Down
1 change: 1 addition & 0 deletions Procfile
@@ -0,0 +1 @@
web: vendor/bin/heroku-php-apache2 public/
34 changes: 34 additions & 0 deletions app.json
@@ -0,0 +1,34 @@
{
"name": "screeenly",
"description": "Create screenshots of websites through a simple API",
"keywords": [
"screeenly",
"Laravel",
"PHP",
"screenshots",
"puppeteer"
],
"website": "http://screeenly.com/",
"repository": "https://github.com/stefanzweifel/screeenly",
"success_url": "/",
"addons": [
"scheduler",
{
"plan": "heroku-postgresql",
"options": {
"version": "13"
}
}
],
"buildpacks": [
{
"url": "heroku/php"
},
{
"url": "heroku/nodejs"
},
{
"url": "https://github.com/jontewks/puppeteer-heroku-buildpack"
}
]
}
4 changes: 2 additions & 2 deletions app/Http/Middleware/TrustProxies.php
Expand Up @@ -12,12 +12,12 @@ class TrustProxies extends Middleware
*
* @var array|string|null
*/
protected $proxies;
protected $proxies = '*';

/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
protected $headers = Request::HEADER_X_FORWARDED_AWS_ELB;
}
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -17,6 +17,7 @@
"laravel/socialite": "^5.0",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.0",
"league/flysystem-aws-s3-v3": "^1.0",
"sentry/sentry-laravel": "^2.1",
"spatie/browsershot": "^3.40"
},
Expand Down
204 changes: 203 additions & 1 deletion composer.lock

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

1 change: 1 addition & 0 deletions config/filesystems.php
Expand Up @@ -55,6 +55,7 @@
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'visibility' => 'public',
],

],
Expand Down
2 changes: 1 addition & 1 deletion config/logging.php
Expand Up @@ -37,7 +37,7 @@
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['daily'],
'channels' => ['daily', 'errorlog'],
'ignore_exceptions' => false,
],

Expand Down
5 changes: 5 additions & 0 deletions config/screeenly.php
Expand Up @@ -8,4 +8,9 @@
*/
'disable_sandbox' => env('SCREEENLY_DISABLE_SANDBOX', false),

/**
* The Filesystem disk where screenshots are being stored
*/
'filesystem_disk' => env('SCREEENLY_DISK', 'public'),

];
35 changes: 35 additions & 0 deletions database/migrations/2021_01_20_193343_create_sessions_table.php
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSessionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->text('payload');
$table->integer('last_activity')->index();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('sessions');
}
}

0 comments on commit 04af491

Please sign in to comment.