Host your own PaaS (platform as a service) on Amazon Web Services

jamesmurdza

James Murdza

Posted on July 14, 2024

Host your own PaaS (platform as a service) on Amazon Web Services

Dokku is an open-source PaaS that allows you to deploy and host multiple applications on a single server. Its functionality is similar to the backend of a service like Heroku, managing tasks such as scaling, load balancing, and database management.

Here's how you can set up Dokku from scratch on AWS:

1. Launch the server

In the AWS control panel, create a new EC2 instance.

  • Select Ubuntu 12
  • Create a new SSH key pair
  • Allow public SSH, HTTP, and HTTPS access to the server

2. Configure DNS

Let's assume your domain is mydomain.com, and you want to host applications as appname.mydomain.com.

In your DNS control panel, create two records:

  • A Record pointing @ to the EC2 instance's public IP address
  • A Record pointing * to the EC2 instance's public IP address

3. Setup the server

SSH into the EC2 instance and install Dokku:

wget -NP . https://dokku.com/bootstrap.sh
sudo DOKKU_TAG=v0.34.6 bash bootstrap.sh
dokku domains:set-global mydomain.com
cat ~/.ssh/authorized_keys | dokku ssh-keys:add admin
Enter fullscreen mode Exit fullscreen mode

4. Create a test application

On the same EC2 instance, run:

dokku apps:create myapp
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
dokku postgres:create railsdatabase
dokku postgres:link railsdatabase ruby-getting-started
Enter fullscreen mode Exit fullscreen mode

5. Set up SSH authentication

On your local machine, add the following to .ssh/config:

Host mydomain.com
    HostName mydomain.com
    User dokku
    IdentityFile ~/ServerKey.pem
Enter fullscreen mode Exit fullscreen mode

6. Deploy a test application

Then, on your local machine, run these commands to deploy a test application:

git clone https://github.com/heroku/ruby-getting-started
cd ruby-getting-started
git remote add dokku dokku@example.com:myapp
git push
Enter fullscreen mode Exit fullscreen mode
đź’– đź’Ş đź™… đźš©
jamesmurdza
James Murdza

Posted on July 14, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related