DreamFactory Deployments with CloudFoundry

From DreamFactory
Jump to: navigation, search
DreamFactoryInstallationDreamFactory Deployments with CloudFoundry
(Launching DreamFactory)
(Launching DreamFactory)
Line 78: Line 78:
Navigate to the URL given. As everything falls into place, you’ll get the first user login for DreamFactory.
Navigate to the URL given. As everything falls into place, you’ll get the first user login for DreamFactory.
[[File:Screen Shot 2017-10-23 at 5.01.44 PM.png|350px|none|left|DreamFactory Success]]]
[[File:Screen Shot 2017-10-23 at 5.01.44 PM.png|400px|none|left|DreamFactory Success]]]

Revision as of 00:15, 24 October 2017

This Wiki tutorial applies to both Pivotal and IBM Bluemix.

Dreamfactory can be deployed as a CloudFoundry manifest and launched in both the Pivotal and IBM BlueMix Platforms. This requires a bit of restructuring of the source code but can be easily done.

To set things up, the DreamFactory source needs to be pulled down and composer run first, so the necessary vendor packages can be brought in. Next, the newly updated source files (inflated by Composer) needs to be placed in a separate directory under the manifest file. This essentially becomes our “App” package for CloudFoundry.

Here’s a step-by-step guide on the basics of setting things up. This demo will use the open source version of the product with the default Sqlite database but should be a good place to get started for further development.

Install DreamFactory (Temporarily)

First, let’s create a temporary directory to stage our work.

mkdir cf-dftemp

Next, pull down the dream factory source into a directory called “htdocs”.

git clone https://github.com/dreamfactorysoftware/dreamfactory.git ./htdocs

Next, install DreamFactory and its dependencies with Composer in the new directory.

cd htdocs

composer install —no-dev

Let composer install the dependencies and then we’ll next need to move some files around.

Moving Files Around

Some of the config files for CloudFoundry are carried along with the DreamFactory source. You will need to move these files up a level above the ./htdocs directory.

These directories and files are as follows:

CloudFoundry Files

You must move all these files up a level, however, keep a copy of composer.lock within the original directory, so just copy that one to the higher directory.

When you’re finished, your basic structure should look like this:

Cloud Foundry File Structure

Now that we’re finished moving things around, you’ll need to finalize some config settings before doing a cf push.

Further Config

Open up the manifest.yml file. Replace the [app_name] placeholder with something unique to your development space.

Replace app_name

Here is where you can also pass env variables into the container. Notice APP_DEBUG is set to false, but you could change that to true. Laravel will pick up the environment variables you specify here.

The .bp-config (PHP BuildPack config) directory is where you will specify any overrides or additional PHP modules which get installed. We’ve set up the minimum required modules and overrides for DreamFactory to run with the default Apache install, but you can modify these files to align with your own setup. For more information on overriding the BuildPack, navigate over to the build pack documentation on CloudFoundry: http://docs.cloudfoundry.org/buildpacks/php/index.html.

Adding Paths in composer.json

Because we moved composer.json without its permission, we have to update some of the paths in our composer file to add the htdocs directory so the autoloader will know where to find things.

In the autoload section, go ahead and add the htdocs path like this:

Composer Autoload Mods

Additionally, add the htdocs/ path to the artisan commands as well:

Composer Artisan Mods

There’s one more thing we’ll have to do before we can launch, and it has to do with the empty cache directories that DreamFactory needs to write to. Basically, the existing BuildPack version doesn’t seem to push up empty directories, so we need to trick it into pushing those directories up as well by placing a dummy file. For ease of use, simply run the following to put an empty file in the DreamFactory cache directories.

From your Cloud Foundry root directory:

touch htdocs/storage/framework/cache/.txt
touch htdocs/storage/framework/sessions/.txt
touch htdocs/storage/framework/views/.txt
touch htdocs/bootstrap/cache/.txt

Now you’re ready to launch.

Launching DreamFactory

From your Cloud Foundry root directory:

cf push

During the upload, Composer will run again and fill everything out for you during the launch. You should get a URL “receipt” when it’s done:

Cloud Foundry Push

Navigate to the URL given. As everything falls into place, you’ll get the first user login for DreamFactory.

DreamFactory Success