How I deployed a Julia web-app using Genie framework with Docker

Julia is a high-level, high-performance dynamic programming language for numerical computing. Genie is a full-stack MVC web framework that promotes a streamlined and efficient workflow for developing modern web applications. I’ve put together a Dockerfile that helps in the deployment of a Genie web app, where the setup for the running environment and the serve process have been configured.

Dockerfile

You can find the gist of this Dockerfile here.

  1. An official Julia 0.6 base image is used, since Genie requires Julia v0.6.x.
  2. A few system dependencies such as unzip, build-essential are installed with apt-get(the reason why is stated in the next section).
  3. The Genie web-framework requires a few package dependencies, which are saved asdeps.jl. This is like a package.json listing the dependency packages.
deps.jl

So any package that is to be added to the project can be mentioned here with Pkg.add(<package_name>) or Pkg.clone("git://example.com/path/to/Package.jl.git") to this file.

4. The script is executed with RUN julia deps.jl. The packages are fetched during the first deployment and this process is cached for further deployments, unless there’s a change in the file.

5. The Genie web-app source code is placed at app directory which is set as the WORKDIR.

├───Dockerfile
├───deps.jl
├───app
     └─── config/routes.jl
     └─── genie.jl
     ...

6. We start the server with$> bin/server on the container, which starts the server and listens at 0.0.0.0:8000.

Issues that I came across during implementation:

  1. The Genie site mentions AppServer.startup() to run the web server, and since it can only run on a genie interpreter, it isn’t possible to run in the executable section of CMD . Hence as mentioned in some deeply buried line in the Genie docs, we start the server with the bin/server command.
  2. During deployment, the build kept failing throwingLoadError: could not spawn `unzip -x ... . I later found out that the Julia docker image doesn’t come with the necessary building tools for building the packages during runtime. So, packages like unzip ,make,build-essentialare installed in the system to build the package dependencies successfully. More on this issue.
HttpParser Build Error

I’m currently interning at Hasura. With the Hasura platform, you can deploy anything that can be dockerized, with just a git push. So, I’ve put together a Hasura quickstart for the Genie framework.

To try a sample Julia Genie project on the Hasura platform (it’s free and it’ll only take you a few minutes):

  1. Install the Hasura CLI tool.
  2. Run this command (you can copy the entire section below and run in one shot).
hasura quickstart anirudhm/hello-julia-genie && 
  cd hello-julia-genie &&
Deployed app

The sequence of commands above will result in your browser window opening with a Hello World Genie app deployed. Make changes and git push to deploy again!

Read more about this quickstart here: https://hasura.io/hub/project/anirudhm/hello-julia-genie.

I would love to hear your feedback on this, let me know in the comments below :)

The Hasura platform is a PaaS + BaaS for the container era. Check it out here: https://hasura.io.


Hasura is an open-source engine that gives you realtime GraphQL APIs on new or existing Postgres databases, with built-in support for stitching custom GraphQL APIs and triggering web hooks on database changes.


Hasura

Hasura

The Hasura GraphQL Engine gives you realtime, high performance GraphQL on any Postgres app. Now supports event triggers for use with serverless.

Read More