Ok, so Heroku is a nice but kind of expensive PaaS solution for hobby projects ($7/month per dyno). They have a free tier but apps there are deployed on-demand and thus have a nasty start-up delay. In addition, they will autosleep after 30min. As an alternative, let’s use Dokku the “Docker powered mini-Heroku”. They also have a another nice slogan: “Own Your PaaS. Infrastructure at a fraction of the cost”. Sounds good to me. In essence, Dokku gives you your own Heroku. After installation you can push Heroku-compatible applications via git. They autobuild using Heroku buildpacks and then run in isolated containers.

Meet dokku
Meet dokku: The smallest PaaS implementation you’ve ever seen

To host Dokku, there are multiple options and people seem to like Digital Ocean who provide a Dokku droplet so you start deploying pretty much right away. But we want to go even cheaper (cheapskate, you know)! As an alternative, I will present a solution that’ll cost you about 3 bucks a month and you can potentially host multiple apps with this (depending on your RAM and disk requirement).

Start a Virtual Private Cloud instance

We need a virtual server/ Virtual Private Cloud (VPC) instance to install Dokku. I chose a German hosting company called Hetzner. I use the base-level CX11 vCPU instance that features 1 vCPU, 2GB of RAM and 20GB NVMe SSD and 20TB of traffic. Then I choose the linux system for the instance (I opted for Ubuntu 18.04 LTS). Next I create a passwordless ssh key and add the public key to the instance.

Install Dokku

Now we ssh into the instance and first set the hostname (replace the IP and hostname with your info).

echo "100.100.100.100 dokku.mydomain.net dokku" >> /etc/hosts

We also add the dokku repository to the system package control (incl. GPG keys).

wget -nv -O - https://packagecloud.io/gpg.key | apt-key add
echo "deb https://packagecloud.io/dokku/dokku/ubuntu/ bionic main" \
    > /etc/apt/sources.list.d/dokku.list

Then we proceed to update the packages and install docker dependencies.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates \
	curl software-properties-common

Now we add another repository (this time for docker):

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) stable"

Finally we install docker-ce and dokku to the system.

# When asked, select YES to enable web setup
sudo apt-get update
sudo apt-get upgrade

sudo apt-get install docker-ce
sudo apt-get install dokku

You now also should have a new user and group Dokku in the system

id dokku
# uid=1000(dokku) gid=1000(dokku) groups=1000(dokku),4(adm),999(docker)

If all went well the service should be running by default after the installation (service name: dokku-installer.service). To check type this into your terminal:

systemctl status dokku-installer.service
systemctl is-enabled dokku-installer.service

Finish the installation by adding core dependencies:

dokku plugin:install-dependencies --core

On the machine use the dokku command to start and stop apps, see logs and configure things. See the help pages here for details.

Deploy an app

Dokku relies on git for deployment. First, make sure you have a local repository setup on your local machine (i.e. git init, …). Then you need to add a deployment remote where the app will be pushed to (this is your dokku server you just set up). In the command below, my-app will also be used by dokku to create your app subdomain when deployed. Thus, the command will host your app at my-app.mydomain.net . With git push you simply deploy and trigger a rebuild if the app already exists. Done.

git remote add dokku [email protected]:my-app
git push dokku master

Note: For deploying multiple apps you also want a domain hoster that allows you to set wildcard DNS records. I started using Porkbun for hosting my apps at http://cwerner.ai (note that this address redirects, to see a live app go here). They are cheap, offer good features (wildcard DNS entires included), and people seem to like them.

A wildcard DNS record looks like this (replace the ip-address with your IP from your VPC instance):

A   *.mydomain.net  100.100.100.100  

Pitfalls

There are some things that you should watch out for.

If you are ever stuck with this error message

 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:my-app'

There a a couple of things you should check:

Insufficient memory

Check that your servers’ disk and memory are sufficient. I discovered that the Ubuntu 18.04 image has only a small swapfile allocated so I manually increased that to 4GB just to be sure.

# increase swapfile to 4G
sudo swapoff -a
sudo dd if=/dev/zero of=/swapfile bs=4G count=102
sudo mkswap /swapfile
sudo swapon /swapfile

Insufficient disk space

Docker can really fill up your hard drive. So if you experiment a lot it might also be a good idea to clean up old stuff like so:

Delete volumes:

# https://github.com/chadoe/docker-cleanup-volumes
docker volume rm $(docker volume ls -qf dangling=true)
docker volume ls -qf dangling=true | xargs -r docker volume rm

Delete images:

# http://stackoverflow.com/questions/32723111/how-to-remove-old-and-unused-docker-images
docker images
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

docker images | grep "none"
docker rmi $(docker images | grep "none" | awk '/ / { print $3 }')

Delete containers:

# http://stackoverflow.com/questions/32723111/how-to-remove-old-and-unused-docker-images
docker ps
docker ps -a
docker rm $(docker ps -qa --no-trunc --filter "status=exited")

If this stuff does not help you might need to upgrade your machine or attach a volume to your instance to offload stuff.

Conclusion

I think this a neat possibility to bring apps to live for cheap. Plus, you also learn a bit about PaaS and devops along the way. I will illustrate how to actually build a python based webapp in another post soon.

Comments

girAnigo

TIKTOK Musical.ly Hack 2019.

tiktok free fans or from this link hack for tiktok

Tiktok Hack Download Tiktok Hack Download How To Hack Musically 2019 How To Hack Musically To Get A Crown How To Hack Musically And Get Coins Tik Tok Hack Mod App Download Tiktok Hack Tools How To Hack Musically To Get Followers Musically Followers Hack 2019 How To Hack Musically Likes Tiktok Online Hack Coin Generator 2019 Tiktok Coin Hacks How To Hack Musically Without Human Verification Tik Tok Fans Hack Online Tiktok Hacks Tiktok Hack Generator Tiktok Hack Apk Download Tiktok Hack Like Tiktok Growth Hack Tik Tok Tricks Tiktok Hack App Tik Tok Fans Generator No Human Verification Tiktok Hacks 2019 Online Tiktok Hack Mod Tik Tok Followers Hack Website

ltonbor

Free Hack for ROBLOX RX GENERATOR

ROBLOX HACK 2019

KW: Roblox Robux Maker 2019 Roblox Hack Pc 2019 Roblox Free Robux 2019 Roblox Robux Generator 2019 Robux Generator Site 2019 Free Roblox Accounts 2019 Roblox Robux Generator 2019 Roblox Generator 2019 Free Robux No Verify 2019 Get Robux Free 2019 Free Robux Codes 2019 Real Robux Generator 2019 Roblox Cash Hack 2019 Robux Cheat 2019 Roblox Free Robux No Human Verification 2019 Roblox Hack No Survey 2019 Roblox Generator 2019 Free Robux No Verify 2019 Roblox Hack No Human Verification 2019 Roblox Generator No Verification 2019

ltonbor

TIKTOK Musical.ly Hack 2019.

tiktok hacks

or from this link

here

Tik Tok Unlimited Likes Hack Tiktok Coin Hacks Tik Tok Followers Hack Ios Tik Tok Tricks How To Get 60 Likes On Musically Musically Iphone Hack 2019 Be Famous On Tiktok Tik Tok Fans Hack Generator Musically Generator Ios Android Tik Tok Fans Hack 2019 Tik Tok Slow Motion Hack Deutsch Musically Ios Hack Tik Tok Likes Hack Tik Tok Like Hack Apk Download Tik Tok Kena Hack Tiktok Hack Tool Generator Hack Premium Tik Tok Kena Hack Tiktok Hack App How To Hack Tik Tok Account Tiktok Generator Online Coins Tiktok Growth Hack Tiktok Hack Hearts

ltonbor

site MARCH UPDATED!!

kw: GET INSTANT! Tik Tok Hack Android 2019 CHECK IT ** GET INSTANT! Tik Tok Hack Ios CHECK IT ** Tik Tok Crown Get Generator 2019 GET INSTANT! Tik Tok Hack Fans CHECK IT ** Musically Crown Get Generator 2019 Tiktok Hack 2019 GET INSTANT! TikTok Hack for iOS Android v. 4.21 GET INSTANT! TikTok iPhone Fans Hack Generator Free GET INSTANT! TikTok Following Generator 2019 GET INSTANT! TikTok iPhone Fans Hack Generator Free GET INSTANT! Tik Tok Hack Android 2019 CHECK IT ** GET INSTANT! Tik Tok Hack Ios 2019 CHECK IT ** GET INSTANT! Tik Tok Fans Generator Ios Android CHECK IT ** Tik Tok Crowns Hack 2019 Tik Tok Crowns Free 2019 Tik Tok Heart Hack 2019 Musically Crowns Free 2019 Tik Tok Heart Hack 2019

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...