Simple and fast way to install sass in container ubuntu 14.04? - ruby

I want to run a script that compiles my sass in a "build" container.
Since this container will repeatedly be restarted I need a robust and quick way to install or use sass. (including ruby and dependencies)
Is there a simple way for sass to be available in a container for scss compiling?
There is a solution using a ruby container but this is not possible in my case since i already need a specific container image for the build itself.
Using another container and named volumes is also not possible in my case.

You can make a Docker image that inherits the specific Ruby image you need, add your changes to it, and use it instead.
For example, if you currently use debian:jessie, then you can create a new Dockerfile with:
FROM debian:jessie
# Now you install all the dependencies including Ruby... etc
RUN gem install sass
Then you can build and image from that file, and publish that image to a docker registry, and use it instead of the one you are currently using.
Take a look at the source code of some Ruby docker image to see how you can install Ruby and dependencies. Ofcourse, you are free to install it however you want (natively, using rbenv or using rvm... etc).

Related

How to enforce bundle install location

I come from a Python and JavaScript background.
When developing a JavaScript project, dependencies are installed in a node_modules directory in the project root.
When developing Python project, typically virtualenvwrapper is used. In this case dependencies are installed in a virtual environment, which is located in ~/.virtualenvs/<project_name> by default.
Now I need to use a ruby tool for a project. The tool that appears to be the most promising for a similar setup as described above, is bundler.
However, the default installation location for bundler is system-wide. I consider this to be harmful.
For one of my systems, it will prompt for a password, at which point I can still abort.
However, for my other system I can write into the global ruby installation. I'm using a homebrew installed ruby here. Bundle will just install dependencies globally.
I know I can specify the installation location by adding --path, but this is easy to forget.
One way to enforce an installation path is by committing .bundle/config. It would just have to contain this:
---
BUNDLE_PATH: "."
However, some googling around shows that it's not adviced to commit this file.
What is the recommended way to prevent accidental global installations using bundler?
Who's to say it will be accidental? It really depends on what context you're talking about here. I have my Ruby set up so that bundle install works without requiring sudo, it's all done through rbenv automatically. The same is true with rvm if done as a user-level install.
When it comes to deploying apps and you want to make sure it's deployed correctly, that's where tools like Capistrano come into play: Create a deployment script that will apply the correct procedure every time.
Checking in a .bundle/config is really rude from a dev perspective, just like checking in any other user-specific preferences you might have. It causes no end of conflict with other team members.

A variation on internally distributing a rails app

I have written a ruby service that I want to package and distribute internally to a specific environment (a standardized linux host). After digging around a bit for the best ways to create a distribution, I've come across a lot of blogs and answers here that recommend bundler and gem packaging as well as a lot of binary distribution options (e.g. traveling-ruby), but these all seem like a bit too much for a relatively simple service that will get deployed to a known environment. I want to create a distribution that doesn't require dependencies to be resolved at deploy time (e.g. bundle install --deployment is not the approach I want).
So with this in mind, is there an available framework that is commonly in use by ruby apps that would create a redistributable package with all dependencies included in it? I am currently doing this in 2 steps and wondering if there's a "better" ruby-way of doing it - something along the lines of gem build ... that creates dependency-inclusive archive?
# Assuming `bundle install` was run on developer workstation and there's a `Gemfile.lock`
$ bundle install --deployment
$ tar zcf ../my-app.tar.gz ./
my-app.tar.gz can now be distributed and if I have an executable to run it with, I can do so with bundle exec bin/run from within the directory after it's extracted. This a good approach?
I've seen a gem called crate that might be able to work....

How should I bundle pandoc with my OpenShift application?

I've been running jekyll on OpenShift using https://github.com/openshift-quickstart/jekyll-openshift. I want to be able to rebuild my web site automatically in order to future-date posts and not have to rebuild/reupload in order to publish them. This means that I have a cron job running on OpenShift that rebuilds my jekyll site, adapting the deploy bash script from the OpenShift cartridge I am using. So far, so good.
Now I want to use pandoc in place of kramdown. Now I have a problem. How do I install pandoc as part of my application's deployment to OpenShift?
I've searched the web for an hour or so. I'm getting conflicting reports. Use puppet. Build from source, which starts with "Install the Haskell platform". I don't mind the work, but I'd like some idea which path to go down before doing down them all and tearing my hair out.
So... which path would you choose and which articles can I read to guide me through learning what I need to learn in order to do this?
Thank you.
Pandoc is written in Haskell, so you'll have to build it using cabal or stack. However once built, you can move the binary to your server:
From Installing Pandoc:
It is possible to compile pandoc such that the data files pandoc uses are embedded in the binary. (The executables in the binary are built this way.) The resulting binary can be run from any directory and is completely self-contained.
cabal update
cabal install hsb2hs
cabal install --flags="embed_data_files" pandoc pandoc-citeproc

Integrate Jekyll to run into WebStorm on Windows

Is it possible to run Jekyll as External Tool into WebStorm? (same for RubyMine, IntelliJ IDEA, ...)
The most obvious thing is to run the jekyll.bat file:
...but this doesn't work.
I haven't found any solution so after some trial+error I discover this working configuration:
In this example I am using: RubyInstaller + gem install jekyll.
If you prefer using straight Ruby+DevKit then Program and Parameters paths must be changed according.

How can I run SASS without installing?

I wanted to use SASS on our company's web app but I can't install any programs on production machines. Everything I searched about SASS required you to run an installation program like gem and also required HAML.
I was hoping to find just a script that processes scss files without needing to install anything else.
Well... if you have Ruby available, you could checkout the Git repository of Sass (https://github.com/nex3/sass). Do so by either typing git clone https://github.com/nex3/sass.git or just downloading it.
Then you could use the interactive Ruby console by typing irb. Try to require 'sass/lib/sass' (this one here) and run Sass.compile_file 'my_styles.css'.
Otherwise... why are you trying to do that? You can also install sass locally, run sass --watch on your sass folder and it compiles your scss files automatically into css files - which you can deploy on your production environment.
If you can run java program in your build system, you could use JRuby for compiling sass. See this answer for more details
Here's a solution for using Sass without using the command line or installing dependencies. It works with Windows, OS X, and Linux. It has a graphical interface, and no installer, just unzip and double-click.
http://scout-app.io
You can also use the java library https://github.com/scireum/server-sass which can be embedded into any java based web-app. It will compile sass on the fly and return the resulting css. This is especially useful if the Sass sources change (i.e. for customizing reasons) and an ahead of time compilation is not possible. (Note: I'm the author of the project - and it is also not yet a complete implementation of the Sass standard).
Alternatively, what you could do is:
Install Ruby
Download the Sass Gem
Navigate to download location
Run: gem install sass-3.3.4.gem
Voila! Sass is installed.
Use the online Sass compiler SassMeister. You just have to paste your sass code on the left panel and get the css code on the right.

Resources