DEV Community

Kostja Appliku.com
Kostja Appliku.com

Posted on • Edited on

Tired of Deployments, built my own Heroku

This article is brought to you by the first deployment service, dedicated specifically to Python & Django Appliku.com.
Never manage a server again.
Deploy your Django app in 5 minutes.

TLDR: I got tired of deploying my Django projects, went to Heroku, and got burnt by their invoices, built my own SaaS to deploy apps to existing clouds.

Story begins with custom software development agency

6 Years ago I started yet another agency where we were building custom solutions for businesses that needed automate time-consuming tasks:

  • Semi-automated task distribution for a large service company,
  • Big e-commerce businesses,
  • Generation of construction documentation
  • Many smaller projects.

It was an interesting journey.

I loved what we've built. The money we saved. Manual labor we got rid of(well, not everyone was happy about the last part of course).

It lasted for 5 years and I loved most of what we had to do.

But one thing was annoying every single time.

Every now and then I needed to spin up a new project and set up a test environment and then production one.

Deployment was a pain every time

During that time I have experimented with different deployment approaches and tools:

  • Used Fabfile,
  • Added CI/CD – first Atlassian Bamboo, then GitLab
  • Used Supervisord, then Docker,
  • Bare-metal servers, Digital Ocean, Linode.

At some point, I came up with a number of scripts that used docker-compose and GitLab CI to start deployment on new commits pushed to the repository.

But for each new project, a lot of manual work had to be done, it was human-error prone and took a full day to set everything up:

  • .gitlab-ci.yml
  • docker-compose.yml
  • set up Nginx and let's encrypt
  • databases
  • list of small things goes on

I loved it when a new client project came up, but I feared going over that process again and again.

I thought there has to be a better way.

Let's give Heroku a try

At that time we came up with a couple of our own side projects, where we use Heroku.

It was such a pleasant experience.

I was "WOW"-ing on every step.

I literally spent zero time on anything DevOps.

I moved a couple more projects there, that was easy. None of those projects were generating any revenue since it was hobby sites.

Then the time came and I received SMS from the bank about Heroku charging my card. At that moment all excitement went away.

Here comes Heroku Invoice

In 2 months Heroku spendings climbed from $15/mo up to $80/mo. For hobby projects.

I have immediately disabled those sites. One I moved off, as the only one that we were interested in.

This coincided with a drastic change in my personal financial situation. I was completely broke for several months.

Getting back on track, seeking for the idea

When I solved my financial issues, I had time to think about what to do next.

We have finished with custom software development.

What was left after doing that business clearly was the pain from deployments and pain from paying for Heroku.

I wanted to get back to some of our hobby projects.

I had time to make it the right way and enjoy doing it.

I wanted something as pleasant as Heroku, but I didn't want to pay that much for that.

Light bulb

It became clear to me: I need to build my own Heroku.

At that time on IndieHackers, I stumbled upon Hatchbox.io for Ruby and heard about Laravel Forge for PHP.

I treated that as validation for a similar tool but for Python/Django.

I came up with a name for it a month later: Appliku.

I started from bash scripts for building Docker, spun up a Django up to manage them, and iterated on that for 17 months to this moment (Sun, 16th Aug 2020).

What do I have now?

  • Automated provisioning of servers on both AWS and DigitalOcean
  • Server setup (Docker, Nginx, Let's Encrypt)
  • Building apps from the source code on GitHub Repo
  • An almost as good interface as Heroku
  • Heroku Config Vars Sync for those who are trying to move off Heroku step by step.

What is under the hood?

Django application is the core of the product.

The frontend is built with Angular based on mdbootstrap.com Angular Package.

Tons of background tasks run by Celery.

When a user requests creation of a new server – Appliku talks via API to Digital Ocean or AWS to provision it.

When Server is provisioned, with help of the Paramiko module Appliku connects to the server over SSH and runs the setup script.

When the setup is complete – you can deploy your app.

App creation consists of naming your app, picking repository and branch, and the server you want to deploy to.

The only requirement for the app is having a Procfile.

I figured that since I was moving off of Heroku, there must be others who do the same. And I liked this idea of having processes in the code itself rather than specifying them in UI.

Procfile is a text file where you specify what processes are needed to be running for your app to operate.

web: python gunicorn wsgi:app
release: python manage.py migrate
celery: celery worker -Q default
Enter fullscreen mode Exit fullscreen mode

"web" tells us that this process should accept HTTP connections.

"release" is what get's executed on every release.

Other processes have no special meaning.

Appliku asks what programming language you use to run the app. Right now supported languages are Python, PYPY, PHP, and Node.

For complex builds, we allow writing your own Dockerfile.

Heroku Sync is a feature that pulls config vars of the app from Heroku API every minute and updates config vars for the related app in Appliku and rebuilds it.

This has proven to be useful for those who moved part of Heroku Dynos to Digital Ocean with the purpose of reducing expenses. Usually, this is done with memory-hungry background workers.

When you hit Deploy.

Appliku makes your server to:

  • go to your GitHub repo
  • clone the code
  • create docker-compose file(based on Procfile and processes you enabled to run)
  • build the image
  • start it

Also, it requests Let's Encrypt SSL certificate for appname.applikuapp.com domain or any other custom domain you have added.

By making your server do that we ensure that all your code is only stored on your server. The only piece of information from your code we store is the contents of the Procfile.

After the app is deployed it runs without much of the interaction with our app.

If you push new commits - we run the build/deploy process.

Every day we run certbot to check if any of the certificates are about to expire.

Couple words about Nginx configuration.

Nginx vhost is setup in a way that it respects cache headers from your app.

proxy_cache_path /home/app/_cache/sitename.com levels=1:2 keys_zone=sitename.com:10m max_size=1g inactive=60m use_temp_path=off;
location / {
        proxy_cache sitename.com;
        proxy_cache_revalidate on;
        proxy_cache_min_uses 1;
        proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
        proxy_cache_background_update on;
        proxy_cache_lock on;
        proxy_cache_bypass $cookie_nocache ;
        add_header X-Cache-Status $upstream_cache_status;

        proxy_pass http://127.0.0.1:8003;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
Enter fullscreen mode Exit fullscreen mode

This way you can use dummy caching on the application side (like Dummy Cache Backend in Django) in order to generate proper cache headers and the actual caching will happen before the request reaches the backend.

Closing thoughts.

I have built this whole thing alone with the help of my wife that took ownership of most non-engineering tasks.

It is a fun thing to work on. I have learned a lot about Docker, Nginx, Paramiko, Django itself.

I think that this app can help many people besides me to:

  • ship their idea faster
  • avoid doing DevOps
  • solve the frustration for beginners "I built the app, how do I publish it?"

Business-model is simple – you pay Appliku fixed fee for service and pay directly to cloud providers for their services.

There is a free plan on Appliku and AWS gives 1 year for new users.

If you are learning to code or seeking for a (mostly) free and enjoyable way to run your app – I really hope in these 17 months I built a solution that can give you that.

P.S.

I really hope you that hearing about my journey and what I built was interesting and doesn't look like a promotional thing.

It was a really interesting journey, full of excitement, frustration (Hello, AWS Docs!), and the idea of making someone's work easier.

I shared all this here to tell that even big and complex things can be done if you believe in it and if you show up every day (even for 30 minutes) and persistently work on it.

If the app helps someone or the article itself motivates somebody to get up and create something – I will be extremely happy.

Thanks for taking time to read this.

P.P.S.

Nearly forgot about the link to the app: https://appliku.com/

Top comments (41)

Collapse
 
mutale85 profile image
Mutale85

I wish to congratulate you for the brave decision you took to build the project.
I have been thinking of building my own stackoverflow like, question and answers forum. All i need it to be brave like you.

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

Hey, Mutale85!
Thanks for kind words.
I guess this has nothing to do with being brave.
I had the idea, I started playing around with scripts.

Then more scripts, then some UI.
17 months later I am polishing a fully functional app.

The problem is the well-known feature creep.
You need to understand what you are building and what you are not building. List of what not to do is more important. We as engineers can be distracted super easy by a new shiny thing we want to learn/try/etc.

That was the biggest problem.

Hope my thoughts help you on your journey!

Collapse
 
anshulnegitc profile image
Anshul Negi

Well said

Collapse
 
leanwebstart profile image
Serge Lachapelle

Very nice! Congrats, looks great... I am an actual customer of Laravel Forge and Envoyer... these apps are a godsend for devs like me as they make the deployment part so easy...

Wish you all the best... Really looks great...

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

Thanks, Serge!

Thanks for your kind words.

I've seen a lot in tweets and everywhere, that people use Forge and it is a vital part of their stack. That was one kind of thing that kept me going!

Collapse
 
iraqwarvet31 profile image
Larry

I am a beginner myself. I have 5 apps already on heroku and I find myself deleting the less apeasing ones because I would rather not pay. Mind you the ones I delete are still on github. This definitely solves my problem!! Thank you so much!! Its simply amazing that you did this!!! I hope to one day be able to do what you guys do. I have so many ideas but not the skills to make them come alive.

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

Hello, Larry!
Thanks for your kind words!

Yes, with Heroku it is hard to be playing around with multiple apps. Invoices are getting bigger super quick. One of the ideas behind Appliku was allowing running multiple apps (low traffic, non-production environments, etc) without the added cost of running each of them.

This is important no matter what stage in your career or how big is your company. You still need room for experiments without being punished with invoices.

So while on the free plan Appliku allows only 1 server and 1 app, on $9/mo it allows 1 server (doesn't matter which size - you can be as small or as big as you want) and unlimited apps.

So if you choose AWS with their free tier for a year you can be just paying $9/mo for everything and have as many apps as you want. If they don't fit on the server (because of RAM) you can just disable not interesting until you want them back. But your expenses will be the same.

Let me know if you need any help, I know how being a beginner is hard while trying to code stuff, let alone deploying your app :)

Wish you the best!

Collapse
 
abdenasser profile image
Nasser El Idrissi

congratulations @kostjapalovic this is realy an inspiring story and the steps you took towards the final products are really what any dreamers should do with their own product ideas, that's the blueprints, overthinking something is very bad you should always start with at least one solution that solves one specific problem then iterate and you'll find yourself building a bigger solution fo some king od problem a lot of people have without you even knowing about it.

Congratulations again and keep koing sir!

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

thanks for the words of support! helps to keep me going!

Collapse
 
smyja profile image
Smyja

Does this support celery and rabbitmq for django? Also are there tutorials on deployment on Django

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

Hello, Smyja!
Yes, I made the effort so that it is easy to run django with celery and rabbitmq simple.

When you create an app, tap the box with that says "create rabbitmq, postgresql, redis" and the only thing in your app is needed is to respect DATABASE_URL,CELERY_BROKER_URL and REDIS_URL.

In Procfile you add web worker, celery worker.
that's all that is needed to run celery.

Collapse
 
smyja profile image
Smyja

Okay. Also , I can't link my Aws educate account. I keep getting an EC2 error.

Thread Thread
 
kostjapalovic profile image
Kostja Appliku.com

Contact me on 123 at appliku com i will be happy to assist you! I am sure it is something with policies for those credentials you are using.

Thread Thread
 
kostjapalovic profile image
Kostja Appliku.com

This should help.
Check that you have all needed Policies added
appliku.com/articles/how-to-deploy...

Collapse
 
jonathans profile image
Jonathan Sundqvist

Well done!

Functionality wise I'm curious why should I use appliku instead of say dokku? What's the selling point compared to just using something like dokku?

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

Hey, Jonathan!
Great question.
Dokku requires some DevOps knowledge to set itself up. And as far as I know, it is a single server thing, so there is not much way to scale with it when you need it.

Appliku's purpose is to remove the need for knowledge of anything DevOps completely. Couple clicks and you have a server setup and you don't need to care about it at all.
How much time will it take to set up Dokku, especially for the first time? 30 minutes? An hour? 1 server plan in Appliku is $9/mo.

Right now, Appliku only supports single-server deployments too, but I am working on clustering deployments, it will be released this year(can't be more specific at this moment).

So while Dokku solves the problem and I find its existence amazing, there are people with low pain from routine tolerance that just don't want to deal with those manual setups. For such people I made Appliku :)

I hope I have answered your question :)

Collapse
 
jonathans profile image
Jonathan Sundqvist

Thanks a lot for your answer! I'll definitely keep appliku in mind for the future. Especially if I start to need multi-server setups. For the time being I'm happy with dokku for toy projects.

Thread Thread
 
kostjapalovic profile image
Kostja Appliku.com

Sign up for Appliku's newsletter. Clustered deployments are in development.
I will announce there when they are out :)
Thanks for kind words!

Collapse
 
realact profile image
Eli

Excellent article, thumbs up!

Collapse
 
yo profile image
Yoginth

This is awesome! Waiting for "Connect to GitLab"

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

thanks for your kind words! as you can see from interface it is planned :-)) but I cant tell right now exactly when I will make it happen.

Collapse
 
fajarsiddiq profile image
Fajar Siddiq

Awesome article! very useful

Collapse
 
kostjapalovic profile image
Kostja Appliku.com

Thanks, Fajar! 🎉

Collapse
 
hamzanouali profile image
Hamza Nouali

You need to post this on the caprover's slack community. Great work! I will give it a try soon.