special sponsors

Using Compass on a Lando Node Service

Written by: Team Lando Team Lando
Guide Tested: Yes

Some older node based frontend build steps rely on ruby and compass. If you have such a flow we highly recommend you escape dependency hell and migrate your sass build steps to use node-sass which is way faster.

However, if you cannot do this you may run into some issues running compass inside of your node container since this pattern is fundamentally at odds with Lando's one-thing-per-container model.

You can, however, get around it by installing ruby and compose directly in the node service that requires them.

Below is an example that installs ruby and compass using build-steps.

services:
  myservice:
    type: node:12
    build_as_root:
      - apt-get update -y
      - apt-get install ruby-full -y
      - gem install compass
tooling:
  ruby:
    service: myservice
  compass:
    service: myservice

You can verify with:

lando ruby -v
lando compass -v

You should now be able to run any build steps that require ruby and compass as in this example:

services:
  myservice:
    type: node:12
    globals:
      grunt-cli: latest
    build_as_root:
      - apt-get update -y
      - apt-get install ruby-full -y
      - gem install compass
    build:
      - grunt build:sass
tooling:
  ruby:
    service: myservice
  compass:
    service: myservice

FULL CODE EXAMPLE!

If you are interested in checking out the fully-armed and operational source code for this guide then check out this repo here.

Have a Lando question you'd like to see as a guide? Suggest one!
Want to write a Lando guide? Learn how!