How should I bundle pandoc with my OpenShift application? - bash

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

Related

Easiest way to install latest Pandoc and LaTeX on Heroku

I want to build a Markdown to PDF converter running on Heroku using Pandoc and LaTeX that I can send markdown to and it will return a PDF. On my local machine this worked fine without any problem. I am using Pandoc 2.7.3 and pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019).
Now I wanted to host this on heroku, but I just get errors for missing files when I run the pandoc command because the versions are old or don't match.
What is the easiest way to get this to run?
Heroku obviously has some limitations on the slug size (500mb), so a full tex install is not possible. It would need to be a smaller subset.
There are Buildpacks for pandoc and TeX Live, but espacially the TeX Live buildpacks seem to be outdated and is not compatible with the pandoc one if you try to run the latest version. The Apt package seems also to maintain only an older version. Is a docker image maybe the answer? https://devcenter.heroku.com/articles/container-registry-and-runtime
I am not necessarily searching for installation instructions, but rather in which way you would handle that. I am a web developer, not a dev ops, so i am really lost in this LaTeX install mess.

Has anyone managed to add custom icons into Ionic in Windows?

I refer the instructions here
What I did (on Windows):
Install fontforge through web instead of 'brew'
Install SASS through Ruby GEM
Place my-icon.svg inside src/ (of the ionicons-master)
Run the python ./builder/generate.py
I think I am very closed. Until i saw this error message:
windowsError: The system cannot find the file specified
And I think I get even closer when I saw the last post of this link
But, I don't get what it means. I downloaded the .exe but it doesn't work.
Is it the python build only meant for MAC? Has anyone managed to make this work in Windows?

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....

Install wkhtmltopdf on heroku using a java application

I manged to get my spring boot website online on Heroku. But I also use wkhtmltopdf to create a pdf. This works locally but now I have some problems.
Offline it works as follow :
ProcessBuilder pb = new ProcessBuilder
("cmd.exe",
"/c",
" cd C:\\Program Files\\wkhtmltopdf\\bin && wkhtmltopdf.exe "
+ "http://google.com C:\\MainWebApps\\TestApp\\src\\main\\resources\\userstorage\\Google2.pdf");
But how do I install this on Heroku?
Where do I store the temporarily html page so I can create a pdf from it ?
And where is wkhtmltopdf installed on Heroku ?
Can I call the wkhtmltopdf with a processbuilder on heroku?
EDIT
So after the comment of ceejayoz I googled a bit more and did find some interesting stuff.
So for Compile the binaries on Heroku I used this:
heroku run /bin/bash
Then I did a curl of wkhtmltopdf like this:
curl -O http://download.gna.org/wkhtmltopdf/0.12/0.12.0/wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
Then I tried to extract it on the server but without success:
$ tar -xjvf wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
tar (child): wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
EDIT2
I also found this https://github.com/dscout/wkhtmltopdf-buildpack on github.
So I did following :
heroku buildpacks:set 'https://github.com/heroku/heroku-buildpack-multi.git'
echo 'https://github.com/dscout/wkhtmltopdf-buildpack.git' >> .buildpacks
This created a file named .buildpacks but how do I proceed from there on ?
I also found this post but vulcan is deprecated and uses ruby
Using Wkhtmltopdf with Nodejs on Heroku
Can somebody provide me with good information because I am completely stuck with this?
You actually have two problems that you need to solve -
How to install/invoke the executable
How to handle the generated .pdf
Assuming you have the basics of Heroku deployment (push to the Heroku git remote), for #1, #ceejayoz is right - check the binary into your git repository. For example, under a ./bin directory. The root of your project (where the Procfile is) will be your working directory, and you should be able to invoke the program with ProcessBuilder using relative paths.
Caveat - since it looks like you are developing on Windows, you will need to pay attention to ensuring both platform-specific binaries are available, and add some logic to know which one to invoke (for example, by setting/checking a specific environment variable).
I recommend against trying to build with a custom build pack - you will spend a lot of energy for little to no benefit. Aside from the platform issue, you don't need to rebuild a third party tool when your code changes...
The second problem is that you can't leave the generated PDF in place. It will go away when the dyno is restarted (see https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem). Thus, the first thing you should do when the process completes is move the generated file to an external storage service (Amazon S3 is a good starting point).
Hope this helps.
You might want to use wkhtmltopdf-binary. With that solution, you do not need to put wkhtmltopdf executable into your VCS. You can use it for example with Maven or Gradle.

Where can I find a tutorial for installing and running cascading.jruby?

I have Hadoop installed and testing fine, however unable to find any instructions for a n00b on
How to setup cascading and cascading.jruby. Where to place the cascading Jars and how to configure jading to build the ruby assemblies correctly?
Is anyone using jenkins to build this automatically?
Edit: more details
I'm trying to build the example word count job from https://github.com/etsy/cascading.jruby
I've installed
hadoop, and run the tests successfully.
installed jruby
gem install cascading.jruby
jade - https://github.com/etsy/jading
installed ant
created the wordcount sample wc.rb
Run jade to compile the wc.rb to a jar
jade wc.rb
I get the following compile error
Buildfile: build.xml does not exist!
Build failed
RuntimeError: Ant retrieve failed
(root) at /usr/bin/hjade:89
Which makes sense looking at the jade code, but this isn't covered in the example usage? What am I missing here?
Sorry for the delay; this is my first answer, here.
The issue you describe, Jading not being able to locate its Ant build script when called from a symlink, is indeed an issue. I'd recommend just adding your Jading clone to your PATH rather than creating symlinks (or submit a pull request to fix the issue!).
To address some of your other concerns, I've created a Getting Started page in the Jading wiki which may be of some help. It walks you through getting up and running with local and remote cascading.jruby jobs without installing anything besides preqs (Java, Ant, JRuby, and the Hadoop client+config). Included now is a full example wordcount script that should function both locally and on a Hadoop cluster, and has been tested on Etsy's own internal cluster.
And backing up further still to address your question about Jenkins, yes, at Etsy we use Jenkins to build and deploy cascading.jruby (and Scalding) to our cluster. However, that build process does not currently use Jading to produce the job jar. Our build predated Jading and Jading was an attempt to release a cleaner version of the process we go through to build that jar. Our build could easily using Jading (and the original examples came from actual uses on our code), but we have slightly different requirements for the artifacts produced by our build.
If you have any other issues with Jading, feel free to submit issues or pull requests to the github project.
If you are using jruby. You must be using bundler as well. In that case you can add cascading.jruby as a dependency in your gemfile.
You could anyways try installing from your project folder as:
gem install 'cascading.jruby'
Hope this Helps.
I've got the working end to end now.
I had created symlinks to the hadoop, jading binaries in /usr/local/bin
The scripts need to be run from their own directories in order to find the supporting files
i.e. the following works: (assuming the cascading.jruby example is in ~/dev/cascading.jruby.demo/wc.rb
cd /usr/local/jading
./jade ~/dev/cascading.jruby.demo/wc.rb
# creates a jade.jar locally in jading folder
cd /usr/local/hadoop
./bin/hadoop jar /usr/local/jading/jade.jar ~/dev/cascading.jruby.demo/wc.rb ~/dev/cascading.jruby.demo/sampledata/in.txt

Resources