Alessandro Sanino
Jul 21 · 9 min read

Greetings web traveller,

I always had the problem to create cloud architectures when I wanted to create cool applications. If you are like me, you:

  • Are a developer, with Cloud Engineering background
  • Are a curious person who develops a lot of things on its own
  • Usually have no money to setup a development architecture for your projects
  • You want for your architecture to be easily migrable to something more powerful if your startup gets sufficient investment, but you just don’t want to spend money only for a development/staging cloud environment
  • Optionally, you come from Piedmont, a region in the north of Italy, famous for its inhabitants never happy to give money for services (in fact, you can refer to this model also with the name Piemontish Architecture Model or PAM 😂).

Based on these assumptions, I created a collection of services without spending a single penny and I reached all the scalability objectives for a small to medium project.

And now I am going to explain you how to replicate and do it for your project.


We are going to cover what are in my honest opinion the components you need to develop your architecture first, and later attach them each other. The basics components are:

  • A git server: You are going to need this to store your code in multiple repositories and work with your team concurrently without issues
  • A Continuous Integration service: This is used to automatically build and deploy your application to remote servers, check your code when you are doing a PR, and notify all involved people when something important related to code is happening
  • A Container Engine who can run your software on remote hosts. An example of this services is docker
  • A VPS or equivalent host who can run Containerized Applications
  • A CDN to serve static content at the speed of light: you usually use Content Delivery Network to distribute the load of static assets for better delivery speed, due to their caching.

For each one of this components, we must choose a free solution that can interoperate with the others, let’s see how it’s done.

Git service: Gitlab

Gitlab is a software which can come in two modes:

  • Cloud mode is hosted on and allows you to have unlimited private repositories for teams up to 5 people
  • Self-Hosted mode is hosted on your servers and allows you to have full control of the gitlab environment at no cost

NOTE: we are referring to Gitlab Community Edition, other editions have costs you should consider if you want extra services.

Continuous Integration: Gitlab again

Yes, Gitlab comes with an extra feature called Gitlab runners. You can use them to run Continuous Integration pipelines over your code to do deploy, notify and check tasks on commits and pull requests over code stored in gitlab repositories.

Again, we have two options:

  • Host your own Gitlab runners for free in your servers (even localhost) and use them without limits.
  • Use Gitlab set of public shared runners on the cloud and get 2000 build minutes for free per month. This is a good head start if you don’t have free VPS to start your runners into.

Container Platform: Heroku PaaS

Heroku is usually not used as pure VPS but allows (using the container heroku stack) to deploy docker containers and use them on heroku dynos for free for up to 1000 dyno hours per month/account.

Again, this is an awesome start because it allows to deploy apps for free.

It also binds easily with the so-called Heroku addons, which allow to integrate databases, monitoring services, etc… with just a click of a button.

NOTE: Please check the dyno limits to see what are free dynos limits.

There is a problem in this, though: if Heroku web processes (which usually correspond to deployed applications) do not receive HTTP requests in 30 minutes are made sleeping by Heroku itself.

This is good because it allows you to save dyno hours, bad because on next restart you will need to wait for dyno coming back serving requests.

This is generally not true for worker and one-off processes. See Heroku Dev Center for details and explanations.

We are going to use Heroku Container service to deploy via Gitlab our application, but first let’s see how to attach plugins to our our newly created heroku app.

CDN and DNS: Cloudflare

NOTE: this step is optional and works only if you bought a domain, you can buy cheap domains directly on cloudflare website or

Cloudflare is a cloud service whch has multiple features, and different payment plans. On free plan it allows you to have free CDN, DNS and anti DDoS.

If you setup a cloudflare account and migrate the nameservers to their configuration, you will be able to leverage cloudflare caching on your application almost seamlessly.

A case study: the Tryvium Booking Platform

At The Tryvium Company LTD we want to provide best travel experience to all travelers and hotel managers around the world. Thanks to blockchain technology we are able to cut costs and intermediaries, resulting in lower prices.

We are developing a complete suite of software to benefit all the actors in the ecosystem:

  • Booking Platform to serve travellers, allowing them to book hotels and make reservations using crypto and fiat
  • Tryvium All-In-One software to provide the hotel managers all the tools they need to manage their company from all points of view
  • Tryvium Gift Experience to tokenize gift boxes travelers can use to choose between multiple predefined locations

The case study here is the development of the Booking Platform part, where we created the entire development ecosystem using the already cited components:

The full set of components together in a single architecture

To create this, we need to:

  • Connect Gitlab and Heroku
  • Install heroku addons for mongodb and redis
  • Bind Cloudflare and Heroku to allow caching

Gitlab ⤌⤍ Heroku

To connect gitlab with heroku we need to perform some initial assumptions:

  • you registered an account on and
  • you know how to write a gitlab pipeline (see here for additional info)
  • you know how to write a Dockerfile
  • you created an empty heroku application from website

To deploy to heroku from a gitlab pipeline you can use the following example job as inspiration to put yours in the .gitlab-ci.yml file of your project:

- Build Artifacts
- Deploy
# Add some job in "Build Artifacts" stage to prepare the artifacts to push along with the docker image.Deploy to Heroku:
stage: Deploy
image: docker:stable
- docker:dind
- develop
- master
when: manual
- docker login -u _ -p $HEROKU_API_KEY
- docker build -t$APP_NAME/web .
- docker push$APP_NAME/web
- docker run -e HEROKU_API_KEY=$HEROKU_API_KEY wingrunr21/alpine-heroku-cli:latest container:release web -a $APP_NAME

As you can see there are some important things to notice:

  • There is a pipeline variable called APP_NAME which is used to identify your application and must correspond to the name of the heroku app you just created.
  • There is an environment variable called HEROKU_API_KEY which is injected into your pipeline, to retrieve it just go to your heroku account settings and you will find it. After that, you must set it up as repository or group variable in your Gitlab.
  • The heroku cli is used in the form of docker image, to achieve this the wingrunr21/alpine-heroku-cli is used and executes the push to heroku using the Dockerfile you created in the root directory of your project, creating a web process.
  • The gitlab pipeline is executed in a docker container, therefore to work with docker a special service called dind (AKA Docker in Docker) is used to allow the deploy.

After doing that you will see that your heroku application will successfully deployed after a manual trigger on merge requests involving develop and master branches on your repository.

Let’s now connect heroku and cloudflare.

Heroku ⤌⤍ Cloudflare

To serve an heroku application using cloudflare we assume the following:

  • You created an heroku account and deployed your application.
    For convenience, we assume your app name is myapplication , reachable at We also assume that the application runs on a web heroku process.
  • You bought a domain. For simplicity we assume it to be in the explanation.
  • You already moved your nameservers to cloudflare and DNS is properly working.

To connect cloudflare to an heroku application, you must do the following:

  • Go to your heroku application settings, reachable at
  • Differently form what said on the Heroku documentation, which says to point your DNS to heroku, just click on the Add domain button under the “Domains and certificates” section and add

After that you will see your domain on the list. Let’s now configure cloudflare.

  • Go to cloudflare andgo to your domain settings (you can find them at and select DNS tab.
  • Add a new CNAME record like in the following image
NOTE: in this picture we use @ (root address) as address, but you can put any subdomain of your choice

The record to put is CNAME type because heroku does not provide a static ip.

Heroku Addons: Attaching MongoDB and Redis

Heroku addons are particular plugins which enable to run parallel services attached to our heroku application. You can explore them in the heroku add-on repository.

For our case study we are going to attach a MongoDB and a Redis cluster, available for free.

Here the link for the addons:

To attach an addon to our application we must do the following:

  • After clicking on Provision the addon will be enabled for your app
  • Perform the same process with Heroku Redis addon and you will complete the setup
  • Refer to the environment variables generated on your Heroku Application in your code and you will be able to contact the services provided by the addons. In particular MLab creates an environment variable called MONGO_DB_URI and Heroku Redis creates another one called REDIS_URL.

Wrapping things up

As you have seen in this article, you can get up and running a complete professional architecture for your applications without spending money by composing services available for free.

The most interesting fact is that gitlab can serve multiple repositories and heroku can host multiple apps (up to their respective limits for the free tier) so you can host multiple projects by leveraging this as unique DevOps architecture.

Appendix: Useful links

Heroku website:
Cloudflare website:
Gitlab website:
Heroku CLI in docker:
Tryvium website:

I hope you found this article pretty useful. If this helped you in any way, consider following me on github, or donating to the following cryptocurrency addresses:

BTC: 3PZYF93oZ4cyF5nUoD56mCmJsGEWzmDzPrETH: 0x8b48Af3a5B965F94dE7d1870bf2194c2798e4183XTZ: KT1TvQPKfyJxkGBj7RPjcLaf91QKn6JF4z7rSYS: ShmVjaK4bW2LfhbMyx253QvyDbjD1h71yx

Also do not forget to follow Tryvium on facebook, twitter, github and reddit to see the latest updates.

Tryvium has also an official Medium profile where all the development updates are written to allow people to see our progress.

Stay Awesome,

Alessandro Sanino

The Startup

Medium's largest active publication, followed by +502K people. Follow to join our community.

Alessandro Sanino

Written by

CTO at The Tryvium Company | Syscoin Community Developer | Blockchain Researcher | Blockchain Developer and Architect

The Startup

Medium's largest active publication, followed by +502K people. Follow to join our community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade