14
.
11
.
2023
14
.
11
.
2018
Ruby on Rails
Backend
Tutorial

Docker hosted on Jelastic

Marcin Prokop
Ruby Developer

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

RUN apt-get update -qq \
   && apt-get install -y --no-install-recommends \
   libpq-dev \
   git \
   nodejs \
   vim \
   && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY Gemfile .
COPY Gemfile.lock .

RUN bundle install --without test development
COPY . .

RUN chmod +x docker/launch.sh

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

Marcin Prokop
Ruby Developer

Check my Twitter

Check my Linkedin

Did you like it? 

Sign up To VIsuality newsletter

READ ALSO

Is Go Language the Right Choice for Your Next Project?

14
.
11
.
2023
Maciej Zdunek
Backend
Business

SXSW Tradeshow 2020: Get Your FREE Tickets and Meet Us

02
.
10
.
2024
Michał Krochecki
Ruby on Rails
Conferences
Frontend
Backend
Business

How to build effective website: simplicity & McDonald's

14
.
11
.
2023
Lukasz Jackiewicz
Ruby on Rails
Frontend
Design

Thermal Printer Protocols for Image and Text

14
.
11
.
2023
Burak Aybar
Backend
Tutorial
Software

WebUSB - Print Image and Text in Thermal Printers

14
.
11
.
2023
Burak Aybar
Backend
Tutorial
Software

What happened in Visuality in 2019

14
.
11
.
2023
Maciej Zdunek
Visuality
HR

Three strategies that work in board games and in real life

14
.
11
.
2023
Michał Łęcicki
Ruby on Rails

HR Wave - No Bullshit HR Conference 2019

14
.
11
.
2023
Alicja Gruszczyk
HR
Conferences

Lightning Talks in your company

14
.
11
.
2023
Jarosław Kowalewski
Ruby on Rails
Visuality

Stress in Project Management

02
.
10
.
2024
Wiktor De Witte
HR
Project Management

How to find good developers and keep them happy - Part 1

02
.
10
.
2024
Michał Krochecki
HR
Visuality

PKP Intercity - Redesign and case study of polish national carrier

14
.
11
.
2023
Katarzyna Szewc
Design
Business
Frontend

Let’s prepare for GITEX Dubai together!

14
.
11
.
2023
Michał Piórkowski
Conferences
Business

Ruby Quirks

14
.
11
.
2023
Jan Matusz
Ruby on Rails
Ruby

Visuality recognized as one of the Best Ruby on Rails Devs

14
.
11
.
2023
Maciej Zdunek
Ruby on Rails
Visuality
Business

Is the culture of the organization important?

14
.
11
.
2023
Alicja Gruszczyk
Conferences
Visuality

Between the devil and the deep blue sea

04
.
12
.
2023
Mateusz Wodyk
Project Management
Backend
HR

Let’s prototype!

14
.
11
.
2023
Michał Łęcicki
Ruby on Rails
Backend

5 marketing hacks which will make your life easier

14
.
11
.
2023
Maciej Zdunek
Marketing
Design