{"id":261824,"date":"2021-05-28T21:00:57","date_gmt":"2021-05-28T18:00:57","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/"},"modified":"2021-05-28T21:00:57","modified_gmt":"2021-05-28T18:00:57","slug":"how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/","title":{"rendered":"#How to Host Your Own Platform-as-a-Service (PaaS) with Dokku \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a408757af99c\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a408757af99c\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/#Getting_Started\" >Getting Started<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/#Configuring_Dokku\" >Configuring Dokku<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/#Deploying_Applications\" >Deploying Applications<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/#Attaching_App_Domains\" >Attaching App Domains<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/#Adding_SSL\" >Adding SSL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/#Updating_Your_App\" >Updating Your App<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/#Managing_Branches\" >Managing Branches<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-host-your-own-platform-as-a-service-paas-with-dokku-cloudsavvy-it\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Host Your Own Platform-as-a-Service (PaaS) with Dokku \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage aligncenter size-full wp-image-11139\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/05\/772cbeae.jpg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Graphic showing the Dokku logo\" width=\"1602\" height=\"902\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Dokku is a Platform-as-a-Service (PaaS) implementation, which you can self-host on your own hardware. <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/dokku.com\">Dokku<\/a> uses Docker to automatically deploy your code when you <code>git push<\/code> from your terminal.<\/p>\n<p>Setting up a Dokku server lets you quickly deploy new <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>lications using the familiar Git workflow. Hosting costs can be much lower than commercial PaaS solutions and managed Kubernetes offerings. Once your Dokku server\u2019s up and running, launching a new application should only take a few moments.<\/p>\n<h2 id=\"getting-started\"><span class=\"ez-toc-section\" id=\"Getting_Started\"><\/span>Getting Started<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Dokku supports several installation methods. When installing onto bare-metal hardware, use the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/dokku.com\/docs\/getting-started\/installation\">official bootstrap script<\/a> to download the latest version.<\/p>\n<pre>wget https:\/\/raw.githubusercontent.com\/dokku\/dokku\/v0.24.7\/bootstrap.sh&#13;\nsudo DOKKU_TAG=v0.24.7 bash bootstrap.sh<\/pre>\n<p>The bootstrap script will transform a fresh Linux install into a functioning Dokku server. Software dependencies, including Docker, will be downloaded and installed automatically. The process could take up to 10 minutes, depending on your internet connection.<\/p>\n<p>You can run Dokku <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/dokku.com\/docs\/getting-started\/install\/docker\">as a Docker container<\/a>. This is ideal when you\u2019re using an environment where Docker is already available.<\/p>\n<pre>docker run &#13;\n    --env DOKKU_HOSTNAME=example.com &#13;\n    --name doku&#13;\n    -p 3022:22 &#13;\n    -p 8080:80 &#13;\n    -p 8443:443 &#13;\n    -v \/var\/lib\/dokku:\/mnt\/dokku &#13;\n    -v \/var\/run\/docker.sock:\/var\/run\/docker.sock &#13;\n    dokku\/dokku:0.24.7<\/pre>\n<p>Replace <code>example.com<\/code> with the hostname that you\u2019ll use to access your server. Using this example, ports 80 and 443 will be bound to your host ports 8080 and 8443, respectively. Port 3022 on your host will map to port 22 within the container. This port is used for Git+SSH connections.<\/p>\n<p>A volume is created at <code>\/mnt\/dokku<\/code>. Dokku application data will be stored here. The host\u2019s Docker socket is also mounted into the container so that Dokku can interact with the Docker daemon to create new containers.<\/p>\n<h2 id=\"configuring-dokku\"><span class=\"ez-toc-section\" id=\"Configuring_Dokku\"><\/span>Configuring Dokku<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>After installation completes, visit your host\u2019s IP address in your browser. If you assigned Dokku a hostname, you can also use that here. The web installer will appear to guide you through the rest of the setup.<\/p>\n<p>Copy and paste an SSH key into the \u201cPublic Key\u201d field. Dokku will accept any SSH connections made with this key. You can add other keys later using the Dokku CLI.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11141\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/05\/7fffb663.jpg?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"669\" height=\"960\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You also need to configure your Dokku installation\u2019s hostname if it hasn\u2019t been set up. If you\u2019ve got a domain mapped to your machine, enter that here. Otherwise, you can use <code>localhost<\/code> or an IP address.<\/p>\n<p>When a hostname has been set up, Dokku can automatically serve your apps using individual subdomains. If you don\u2019t have a domain available, untick the \u201cUse virtualhost naming\u201d checkbox. Dokku will serve each of your apps on a dedicated port instead.<\/p>\n<p>If you installed Dokku with Docker, web setup isn\u2019t supported. You can add a hostname when creating the container by setting the <code>DOKKU_HOSTNAME<\/code> environment variable. To add SSH keys, you\u2019ll need to connect to the container and use the Dokku CLI:<\/p>\n<pre>docker exec -it dokku dokku ssh-keys add my-key &lt; \/path\/to\/key<\/pre>\n<p>Once you\u2019ve set a hostname and added an SSH key, Dokku should be ready to use. No further administration is possible using the web UI. You interact with Dokku via Git commands and the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/dokku.com\/docs\/getting-started\/installation\">CLI<\/a>.<\/p>\n<h2 id=\"deploying-applications\"><span class=\"ez-toc-section\" id=\"Deploying_Applications\"><\/span>Deploying Applications<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Now, you\u2019re ready to launch your first app! Dokku deployments start with a <code>git push<\/code>. Dokku uses buildpacks (either Cloud Native or Herokuish) to detect your app\u2019s programming language and automatically create a build.<\/p>\n<p>Dokku also supports running <code>docker build<\/code> directly if your project contains a <code>Dockerfile<\/code>. This functionality can only be used when the buildpack-based builders are unavailable for your project. You can get more information on direct Docker builds in the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/dokku.com\/docs\/deployment\/builders\/dockerfiles\">Dokku documentation<\/a>.<\/p>\n<p>The use of buildpacks means that Dokku places few restrictions on how your project is created. If you\u2019re using a popular language and framework, you should be able to <code>git push<\/code> to create your deployment. Here\u2019s an example for a basic React app:<\/p>\n<pre>mkdir my-app&#13;\ncd my-app&#13;\nnpx create-react-app .&#13;\n&#13;\ngit remote add dokku dokku@example.com:my-app&#13;\ngit push dokku master<\/pre>\n<p>The last two lines are the most important. Your Dokku server is added as a Git remote so that you can push code to it. Replace <code>example.com<\/code> with the IP or hostname of your installation. The part after the colon indicates the Dokku project to push to. You don\u2019t need to create it manually.<\/p>\n<p>After the remote has been set up, you\u2019re ready to push code to it. The example command pushes the <code>master<\/code> branch up to Dokku. Dokku will take your project, autodetect an appropriate buildpack, create a Docker image, and deploy your app.<\/p>\n<h2 id=\"attaching-app-domains\"><span class=\"ez-toc-section\" id=\"Attaching_App_Domains\"><\/span>Attaching App Domains<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Dokku deploys your app to a subdomain of your hostname. You can attach a custom domain using the Dokku CLI. Make sure that you\u2019ve set up appropriate DNS records first.<\/p>\n<pre>dokku domains:add my-app example.com<\/pre>\n<p>Visiting <code>example.com<\/code> will now serve your <code>my-app<\/code> deployment.<\/p>\n<h2 id=\"adding-ssl\"><span class=\"ez-toc-section\" id=\"Adding_SSL\"><\/span>Adding SSL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Dokku makes it easy to enable SSL for your apps. You can add a plugin that integrates Dokku with Let\u2019s Encrypt. Once the plugin has been installed, you can acquire SSL certificates with a single command.<\/p>\n<p>First, install the plugin:<\/p>\n<pre>dokku plugin:install https:\/\/github.com\/dokku\/dokku-letsencrypt.git<\/pre>\n<p>Next, configure the Let\u2019s Encrypt plugin with your email address. Let\u2019s Encrypt will use this address to send you any alerts relating to your certificates.<\/p>\n<pre>dokku config:set --global no-restart DOKKU_LETSENCRYPT_EMAIL=me@example.com<\/pre>\n<p>You should add the Let\u2019s Encrypt cron job to make sure that Dokku can renew your certificates automatically:<\/p>\n<pre>dokku letsencrypt:cron-job --add<\/pre>\n<p>Finally, enable Let\u2019s Encrypt for your application:<\/p>\n<pre>dokku letsencrypt my-app<\/pre>\n<p>The Let\u2019s Encrypt plugin will acquire a certificate to cover the domains connected to your app. The certificate will be automatically renewed before it\u2019s due to expire.<\/p>\n<h2 id=\"updating-your-app\"><span class=\"ez-toc-section\" id=\"Updating_Your_App\"><\/span>Updating Your App<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Dokku builds upon the Git workflow. You can update your app by making codebase changes, creating Git commits, and then pushing your branch to Dokku.<\/p>\n<p>When Dokku receives a new push, it uses its buildpacks to construct an updated Docker container. The currently running container will be replaced with the new one after the build completes. Updates are <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/dokku.com\/docs\/deployment\/zero-downtime-deploys\">downtime-less<\/a> and fully automated.<\/p>\n<p>The duration of the build process will vary depending on the size of your app and the technologies that it uses. Dokku waits a further 10 seconds after the build completes before traffic is directed to new containers. This gives any bootstrap scripts a chance to complete.<\/p>\n<p>Dokku can easily be integrated into continuous integration (CI) systems. The final stage in a CI pipeline could be a <code>git push dokku<\/code> to update your live deployment.<\/p>\n<h2 id=\"managing-branches\"><span class=\"ez-toc-section\" id=\"Managing_Branches\"><\/span>Managing Branches<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Dokku usually deploys changes made to the <code>master<\/code> branch. You can choose to use a different branch using a global or per-app setting:<\/p>\n<pre>dokku git:set --global deploy-branch dokku-deploy&#13;\n&#13;\ndokku git:set my-app deploy-branch production<\/pre>\n<p>With this configuration, Dokku will default to deploying from the <code>dokku-deploy<\/code> branch. Deployments for the <code>my-app<\/code> app will be made from <code>production<\/code> instead.<\/p>\n<p>There\u2019s much more to Dokku than the basic deployment we\u2019ve focused on here. The default distribution is intentionally streamlined. Official and community <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/dokku.com\/docs\/community\/plugins\/#official-plugins-beta\">plugins can be<\/a> used to provide services, such as databases and authentication. This allows you to use Dokku for stateful backends as well as for your static frontends.<\/p>\n<p>Setting up a service is <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a>ly a two-step process. You create an instance of the service and then link it into your apps. Multiple apps can be connected to each service instance.<\/p>\n<p>Here\u2019s how you can add a MySQL database to an app:<\/p>\n<pre>dokku plugin:install https:\/\/github.com\/dokku\/dokku-mysql.git&#13;\n&#13;\ndokku mysql:create demo-db&#13;\n&#13;\ndokku mysql:link demo-db my-app<\/pre>\n<p>Dokku will set the <code>DATABASE_URL<\/code> environment variable inside your app container. You can access this variable to retrieve the MySQL connection string. Using Dokku plugins for databases removes the need to manage another external database server.<\/p>\n<h2 id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Docker is a PaaS solution that lets you host your own application platform. Once Dokku is up and running, launching a new app is as simple as a <code>git push<\/code>.<\/p>\n<p>Dokku compares favorably with services such as Heroku, Amazon Elastic Beanstalk, and Google Firebase. It supports a large number of development technologies and means that you\u2019re not tied into a particular cloud provider. You can run Dokku on a cheap cloud-based VM or keep it on your own physical hardware.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/11138\/how-to-host-your-own-platform-as-a-service-paas-with-dokku\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Host Your Own Platform-as-a-Service (PaaS) with Dokku \u2013 CloudSavvy IT&#8221; Dokku is a Platform-as-a-Service (PaaS) implementation, which you can self-host on your own hardware. Dokku uses Docker to automatically deploy your code when you git push from your terminal. Setting up a Dokku server lets you quickly deploy new applications using the familiar&#8230;<\/p>\n","protected":false},"author":1,"featured_media":261825,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/05\/772cbeae.jpg","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-261824","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/261824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=261824"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/261824\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/261825"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=261824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=261824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=261824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}