Deploy a Webpacker app on Engine Yard Cloud


The advent of Rails 5.1 brought along a set of new things, like the ability to use Webpacker and have front-ends built on top of frameworks as React.js.

The Engine Yard deployment process (dubbed serverside) is able to deploy and run Webpacker apps, but not without a few tricks.  Below are the steps needed to get a Webpacker app deployed and running on EY Cloud.

Enabling Yarn

By default, serverside uses npm to handle NodeJS modules.  Follow the instructions on the article Using yarn to manage NodeJS modules for assets compilation to have it use yarn instead.

More ey.yml settings

Additional configuration is required for the deployment stages to compile the Webpacker modules properly.  Add the following to your config/ey.yml file:

  precompile_assets: true
  precompile_unchanged_assets: true
- app/assets
- lib/assets
- vendor/assets
- Gemfile.lock
- config/routes.rb
- config/application.rb
- config/requirejs.yml
- app/javascript

Sharing Webpacker assets between deployments

While the steps above ensure that Webpacker assets are compiled, there is also a need for them to be available across deployments to further speed up the deployment process.  Add the code below to a deployment hook named deploy/before_bundle.rb:

# create the shared packs folder. Should be a one-time only task
run "mkdir -p #{config.shared_path}/packs"
# link the shared packs folder to the release being deployed
# so that packs are found even if assets haven't changed
run "ln -nfs #{config.shared_path}/packs #{config.release_path}/public/packs"

Final notes

The above steps should help you get the app deployed successfully.  From here on, your mileage may vary according to further customizations or needs your app may have.  Feel free to reach out to our Support Team by filing a ticket if further assistance is needed.

More Information

For more information about ... See ...
Webpacker on rails website
Webpacker example app
Free tutorial on using React + Webpacker + Rails 5


Article is closed for comments.