-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
fortrabbit deployment guide + index listing #6291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+291
−0
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3fd6374
fortrabbit deployment guide + index listing
907365e
fortrabbit deployment guide + index listing - 80 chars wrap
0b59222
use the right RST syntax + fix typos
5d436af
use the right RST syntax + fix typos
68efc51
better config code-blocks and proper .rst styles
3175235
removed double line breaks
9186532
added/fixed links
d52daa0
some text formats and added missing configuration-block(s)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,289 @@ | ||
.. index:: | ||
single: Deployment; Deploying to fortrabbit.com | ||
|
||
Deploying to fortrabbit | ||
======================= | ||
|
||
This step-by-step cookbook describes how to deploy a Symfony web application to | ||
`fortrabbit`_. You can read more about using Symfony with fortrabbit on the | ||
official fortrabbit `Symfony install guide`_. | ||
|
||
Setting up fortrabbit | ||
--------------------- | ||
|
||
Before getting started, you should have done a few things on the fortrabbit side: | ||
|
||
* `Sign up`_. | ||
* Add an SSH key to your Account (to deploy via Git) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there resources we can link to? |
||
* Create an App | ||
|
||
Preparing your Application | ||
-------------------------- | ||
|
||
You don't need to change any code to deploy a Symfony application to fortrabbit. | ||
But it requires some minor tweaks to its configuration. | ||
|
||
Configure Logging | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
Per default Symfony logs to a file. Modify the ``app/config/config_prod.yml`` file | ||
to redirect it to :phpfunction:`error_log`: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
# app/config/config_prod.yml | ||
monolog: | ||
# ... | ||
handlers: | ||
nested: | ||
type: error_log | ||
|
||
.. code-block:: xml | ||
|
||
<!-- app/config/config_prod.xml --> | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:monolog="http://symfony.com/schema/dic/monolog" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/monolog | ||
http://symfony.com/schema/dic/monolog/monolog-1.0.xsd"> | ||
|
||
<monolog:config> | ||
<!-- ... --> | ||
<monolog:handler | ||
name="nested" | ||
type="error_log" | ||
/> | ||
</monolog:config> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
||
// app/config/config_prod.php | ||
$container->loadFromExtension('monolog', array( | ||
// ... | ||
'handlers' => array( | ||
'nested' => array( | ||
'type' => 'error_log', | ||
), | ||
), | ||
)); | ||
|
||
Configuring Database Access & Session Handler | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
You can use the fortrabbit App Secrets to attain your database credentials. | ||
Create the file ``app/config_prod_secrets.php`` with the following contents:: | ||
|
||
<?php | ||
// Get the path to the secrects.json file | ||
if (!$secrets = getenv("APP_SECRETS")) { | ||
return; | ||
} | ||
|
||
// Read the file and decode json to an array | ||
$secrets = json_decode(file_get_contents($secrets), true); | ||
|
||
// Set database parameters to the container | ||
if (isset($secrets['MYSQL'])) { | ||
|
||
$container->setParameter('database_driver', 'pdo_mysql'); | ||
$container->setParameter('database_host', $secrets['MYSQL']['HOST']); | ||
$container->setParameter('database_name', $secrets['MYSQL']['DATABASE']); | ||
$container->setParameter('database_user', $secrets['MYSQL']['USER']); | ||
$container->setParameter('database_password', $secrets['MYSQL']['PASSWORD']); | ||
} | ||
|
||
// Check if the Memcache component is present | ||
if (isset($secrets['MEMCACHE'])) { | ||
|
||
$memcache = $secrets['MEMCACHE']; | ||
$handlers = []; | ||
|
||
foreach (range(1, $memcache['COUNT']) as $num) { | ||
$handlers [] = $memcache['HOST' . $num] . ':' . $memcache['PORT' . $num]; | ||
} | ||
|
||
// Apply ini settings | ||
ini_set('session.save_handler', 'memcached'); | ||
ini_set('session.save_path', implode(',', $handlers)); | ||
|
||
if ("2" === $memcache['COUNT']) { | ||
ini_set('memcached.sess_number_of_replicas', 1); | ||
ini_set('memcached.sess_consistent_hash', 1); | ||
ini_set('memcached.sess_binary', 1); | ||
} | ||
} | ||
|
||
Make sure this file is listed in your *imports*: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
# app/config/config_prod.yml | ||
imports: | ||
- { resource: config.yml } | ||
- { resource: config_prod_secrets.php } | ||
|
||
# .. | ||
framework: | ||
session: | ||
# set handler_id to null to use default session handler from php.ini (memcached) | ||
handler_id: ~ | ||
# .. | ||
|
||
.. code-block:: xml | ||
|
||
<!-- app/config/config_prod.xml --> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<imports> | ||
<import resource="config.xml" /> | ||
<import resource="config_prod_secrets.php" /> | ||
</imports> | ||
|
||
<!-- .. --> | ||
<framework:config> | ||
<!-- .. --> | ||
<framework:session save_path="null" /> | ||
</framework:config> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
||
// app/config/config_prod.php | ||
$loader->import('config/config.php'); | ||
$loader->import('config_prod_secrets.php'); | ||
|
||
$container->loadFromExtension('framework', array( | ||
'session' => array( | ||
'handler_id' => null, | ||
), | ||
)); | ||
|
||
// ... | ||
|
||
Configuring the Environment in the Dashboard | ||
-------------------------------------------- | ||
|
||
PHP Settings | ||
~~~~~~~~~~~~ | ||
|
||
The PHP version and enabled extensions are configuable under the PHP settings | ||
of your App within the fortrabbit Dashboard. | ||
|
||
Environment Variables | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Set the ``SYMFONY_ENV`` environment variable to ``prod`` to make sure the right | ||
config files get loaded. ENV vars are configuable in fortrabbit Dashboard as well. | ||
|
||
Document Root | ||
~~~~~~~~~~~~~ | ||
|
||
The document root is configuable for every custom domain you setup for your App. | ||
The default is ``/htdocs``, but for Symfony you probably want to change it to | ||
``/htdocs/web``. You also do so in the fortrabbit Dashboard under ``Domain`` settings. | ||
|
||
Deploying to fortrabbit | ||
----------------------- | ||
|
||
It is assumed that your codebase is under version-control with Git and dependencies | ||
are managed with Composer (locally). | ||
|
||
Every time you push to fortrabbit composer install runs before your code gets | ||
deployed. To finetune the deployment behavior put a `fortrabbit.yml`_. deployment | ||
file (optional) in the project root. | ||
|
||
Add fortrabbit as a (additional) Git remote and add your configuration changes. | ||
|
||
.. code-block:: bash | ||
|
||
$ git remote add fortrabbit git@deploy.eu2.frbit.com:your-app.git | ||
$ git add composer.json composer.lock | ||
$ git add app/config/config_prod_secrets.php | ||
|
||
Commit and push | ||
|
||
.. code-block:: bash | ||
|
||
$ git commit -m 'fortrabbit config' | ||
$ git push fortrabbit master -u | ||
|
||
.. note:: | ||
|
||
Replace your-app with the name of your fortrabbit App. | ||
|
||
.. code-block:: bash | ||
|
||
Commit received, starting build of branch master | ||
|
||
––––––––––––––––––––––– ∙ƒ ––––––––––––––––––––––– | ||
|
||
B U I L D | ||
|
||
Checksum: | ||
def1bb29911a62de26b1ddac6ef97fc76a5c647b | ||
|
||
Deployment file: | ||
fortrabbit.yml | ||
|
||
Pre-script: | ||
not found | ||
0ms | ||
|
||
Composer: | ||
- - - | ||
Loading composer repositories with package information | ||
Installing dependencies (including require-dev) from lock file | ||
Nothing to install or update | ||
Generating autoload files | ||
|
||
- - - | ||
172ms | ||
|
||
Post-script: | ||
not found | ||
0ms | ||
|
||
R E L E A S E | ||
|
||
Packaging: | ||
930ms | ||
|
||
Revision: | ||
1455788127289043421.def1bb29911a62de26b1ddac6ef97fc76a5c647b | ||
|
||
Size: | ||
9.7MB | ||
|
||
Uploading: | ||
500ms | ||
|
||
Build & release done in 1625ms, now queued for final distribution. | ||
|
||
|
||
.. note:: | ||
|
||
The first ``git push`` takes much longer as all composer dependencies get | ||
downloaded. All subsequent deploys are done within seconds. | ||
|
||
That's it! Your application is being deployed on fortrabbit. More information | ||
about `database migrations and tunneling`_ can be found in the fortrabbit | ||
documentation. | ||
|
||
.. _`fortrabbit`: https://www.fortrabbit.com | ||
.. _`Symfony install guide`: https://help.fortrabbit.com/install-symfony | ||
.. _`fortrabbit.yml`: https://help.fortrabbit.com/deployment-file-v2 | ||
.. _`database migrations and tunneling`: https://help.fortrabbit.com/install-symfony-2#toc-migrate-amp-other-database-commands | ||
.. _`Sign up`: https://dashboard.fortrabbit.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ Deployment | |
azure-website | ||
heroku | ||
platformsh | ||
fortrabbit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need to add an entry to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be "website" (or "site") instead of "side"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's more like "on the other side of the river"