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.
You can find the gist of this Dockerfile here.
- An official Julia 0.6 base image is used, since Genie requires Julia v0.6.x.
- A few system dependencies such as
build-essentialare installed with
apt-get(the reason why is stated in the next section).
- The Genie web-framework requires a few package dependencies, which are saved as
deps.jl. This is like a
package.jsonlisting the dependency packages.
So any package that is to be added to the project can be mentioned here with
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
├───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:
- 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
- During deployment, the build kept failing throwing
LoadError: 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
build-essentialare installed in the system to build the package dependencies successfully. More on this issue.
To try a sample Julia Genie project on the Hasura platform (it’s free and it’ll only take you a few minutes):
- Install the Hasura CLI tool.
- 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 &&
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.