Docker hosted on Jelastic

Marcin Prokop (b4k3r)
Visualitypl
Published in
5 min readNov 9, 2018

Two years ago we introduced Docker to our company. One of our projects was complex in terms of deployment architecture and scalability. We were looking for a solution which allows us to simplify the process of deployment and scaling client’s instances in the future. Docker turned out as a very good tool to isolate apps into containers with all needed dependencies and treat them as block boxes. They are easily portable from machine to machine and basically, we can host them whenever we want if there Docker engine is installed. I think it doesn’t make sense describing Docker more, because there are already a lot of articles about it, not to mention excellent Docker documentation.

The next question was: where to host our docker containers? There were various options from dedicated servers to PaaS solutions. As a company, we don’t deal with server management and prefer using Heroku for our apps. That’s why we looked more closely at solutions that do not require care of the servers. After long research, we decided to go with Jelastic.

In few words, Jelastic is a complex dev platform which combines Platform as a Service (PaaS) and Container as a Service cloud models. It supports deployment for many technologies, including Python, Java, PHP and Docker as well. With automatic scalability based on pay-as-you-go model you don’t have to care about resources management. Moreover Jelastic came with rich API which is helpful to automate many things outside of their panel. For more information about this platform, I recommend visit this post.

Image from jelastic.com

In this article I will show how to simply deploy dockerized Rails app. Let’s start with the simple Docker image for Rails. I assumed that we have a Rails app which uses an external database (e.g. Postgresql) and has generated scaffold for posts (title and body).

FROM ruby:2.5.1RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
libpq-dev \
git \
nodejs \
vim \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /appCOPY Gemfile .
COPY Gemfile.lock .
RUN bundle install --without test development
COPY . .
RUN chmod +x docker/launch.shCMD ./docker/launch.sh

We are not doing much in this Dockerfile, just installing necessary libs, copy project files, install gems and finally run the application. Also I like put docker things in docker directory. Let’s build it.

docker build -t b4k3r/sample-app .

And push to the registry (can be a Docker or private). Later Jelalstic will fetch the image from this registry to run the app.

docker push b4k3r/sample-app

Let’s move to Jelastic part. The first thing we need to do is create an environment. The environment in Jelastic is like a private space or an independent virtual machine for your application environment. In the environment, among other things, you can put environment variables, define volumes or adjust resources for your app. As you can see, there is also vertical and horizontal scaling. In the vertical scaling, you can adjust resources like ram, CPU by cloudlets. Cloudlet is the unit which represents a specific amount of RAM and CPU clocking. Below, on the right side system automatically calculates estimation cost.

After clicking “Select container” we can find and select our image which was previously built and pushed.

Of course, if we store Docker images on a different repository, we can have access to them through Jelastic as well. Let’s do the same for the database image.

Now we have defined two containers. Let’s move to links and environment variables part. Just like in Docker, Jelastic allows defining a connection between containers of a single environment aka links and environment variables.

Jelastic automatically adds some default environment variables to containers.

We can’t forget about volumes which are useful to prevent losing dynamic data in containers. Jelastic supports it as well, even remote storage!

Basically, that’s it. We configured production environment for our simple Rails app.

Conclusion

In our project we haven’t used many features which Jelastic offers. What interested us, were Docker support and no server management. Did Jelastic do job? Quite good but there were some issues with stability, for example with disappearing environment variables after redeploying containers. Despite this, support from Jelastic team was excellent (I hope now also :) ) and guys was fixing issues as soon as possible. In the next article I will write how we created complex deployment architecture using Jelastic, Docker and Jekins.

If you’re interested in more blog posts like this please visit our Visuality Blog or our Medium Page

--

--