I have a web application that uses the gulp-ruby-sass
plugin and it runs within a container that installs the sass
gem.
This is the Dockerfile:
FROM phusion/passenger-customizable:0.9.19
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
# Build system and git.
RUN /pd_build/utilities.sh && \
# Ruby support.
/pd_build/ruby-2.3.*.sh && \
# Node.js and Meteor support.
/pd_build/nodejs.sh && \
npm install -g gulp jspm yarn && \
npm install [email protected] && \
mv node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /usr/bin && \
rm -r node_modules && \
# Clean up APT when done.
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
EXPOSE 9000
WORKDIR /var/www/
CMD /bin/bash
This is the bootstrap script file (to bootstrap the application):
#! /bin/bash
bundle install
npm install
jspm install
npm config set bin-links false
npm rebuild node-sass
gulp watch
This is the Gemfile:
source "https://rubygems.org"
gem "sass"
And I launch the container this way:
docker run -it --name web -p 9000:9000 --volume $(pwd):/var/www brainy_web sh bootstrap.sh
The problem is that when the gulp task gulp build-css
is executed using docker-compose
, it doesn't find the sass
gem as it is shown in the log: Gem sass is not installed
(complete log here), but when I run the container with bash and execute the bootstrap.sh
file everything runs smoothly.
Any thoughts on how to use sass
with docker
and gulp-ruby-sass
?
UPDATE
I found that executing from the outside the gulp task, it doesn't find either:
docker exec web gulp build-css
I found the solution! I followed the advice from @webert-s-lima and in here: https://stackoverflow.com/a/29999734/532912
I just added the -l
argument when launching the container. The statement would be like this:
docker run -it --name web -p 9000:9000 --volume $(pwd):/var/www brainy_web /bin/bash -l bootstrap.sh