run LocomotiveCMS websites locally in minutes using Wagon and Devstep (Docker)

At Akretion we really love the Locomotive CMS which powers this corporate website and some other of our websites. LocomotiveCMS is all the more exciting as it shares a lot of its technological stack with Shopify, like the Liquid templating language for instance. And Akretion made it possible to integrate LocomotiveCME with Odoo business logic layer seamlessly using the erpify gem. Something exciting we will talk about in an other post…

But in a company where we already ask our collaborators to master Python, not everybody has the proper Ruby runtime locally nor is willing to clutter his computer with all the dependencies. This is where Docker and Devstep really shine. Here is how to hack a LocomotiveCMS in minutes using Wagon in Devstep;

You may first need to install Docker on your computer in case you have been living on another planet over the last months: Don’t forget to give your user the privilege to run Docker as it saves you from doing sudo everytime when using docker.

Here is how this tutorial looks like (recorded after steps 1 and 2 have been done):

1) Install Devstep

install Desvtep (voodoo includes the Devstep image because it’s derived from it. But you should still install the client launcher).

2) Install Java in the Devstep image (LocomotiveCMS requires Java in yui-compressor)

docker run -ti fgrehm/devstep:v0.2.0 bin/bash
developer@aa5578cfaeff:/$ sudo apt-get update
developer@aa5578cfaeff:/$ sudo apt-get install openjdk-7-jre

in an other terminal/tab; note the container id (here aa5578cfaeff from the container shell prompter) and commit the changed image:

docker commit aa5578cfaeff fgrehm/devstep:v0.2.0

That commit will allow us to have Java in all our future containers based on Devstep.

3) Clone an existing Wagon website (unless you want to create a new one and follow the doc).

For instance we will start a blog example from the official LocomotiveCMS tutorial

git clone
cd wisdom-for-wanderers

but because we are lazy we will go straight to the branch containing the final result:

git fetch origin chapter-4.2:chapter-4.2
git checkout chapter-4.2

and because this is no mission critical ERP, we even suggest living on the edge and changing the Gemfile to grab the latest Wagon from git. So you can make this change in the Gemfile:

-gem 'locomotivecms_wagon', '~> 1.4.0'
+gem 'locomotivecms_wagon', git: ''

4) Start a Devstep container to run our website locally using Wagon:

make sure you are inside the wisdom-for-wanderers folder and do:

devstep hack -p 3333:3333

(you may double check where you downloaded/installed the devstep client command)

By doing that, you will enter a new Devstep container where the Ruby Buildpack will fire and converge the dependencies specified in the Gemfile, including the Wagon too to run LocomotiveCMS locally.

5) Start wagon and you are done!

bundle exec wagon serve

Now browse http://localhost:3333 and you should be able to see the LocomotiveCMS blog!

You can now hack the liquid templates in the app folder and the CSS/JS in the public folder and see the changes live (a cool plugin to use is LiveReload for Firefox for instance so you don’t even need to refresh the browser).

6) Next…

Read LocomotiveCMS documentation to learn more Eventually start the process from the initial branch of chapter 1 and walk through the different stages by switching branches and restarting wagon (no need to restart the Docker container itself).

An other thing you can do from here is deploying this local Wagon website to some running Locomotive Engine, possibly in the cloud and this is what we will cover in a next post.

From here you can also typically hack some Locomotive component like Wagon, contribute bugfix and improvements. For that, you should clone that component in some subfolder, for instance vendor/wagon and you should edit the current Gemfile to point to that local folder instead of grabbing it from rubygems or Github. Typically, you can achieve that by commenting the line with gem ‘locomotivecms_wagon’ in your Gemfile and replace it by the path to your local fork such as

gem 'locomotivecms_wagon', path: 'vendor/wagon'

and then removing the Gemfile.lock and starting again the container so that bundle will configure again the dependencies to use your local fork.

Some next Docker tutorial will also teach you how to do magic with Docker and Odoo, so stay tuned…

Lumière sur l'auteur

Raphaël Valyi
Founder - Brazil
Raphael, when he worked in Smile the French IT company, led the most thorough comparative study on ERP OpenSource (OpenERP, Openbravo, Compiere, Adempiere, ERP5 Ofbiz, etc ...) that led to writing a white paper of 120 pages. It has over 5 years experience in OpenERP and achieved more than 10 ...

Esse site usa cookies para melhorar a sua experiência de navegação