Skip to content
VirtualLP Virtual Learning Platform

Practical 8: FOSS-Cloud PaaS – Deploying a Web Application

13 min read Topic 32 of 34 1 hands-on lab

Aim

Deploy a web app on an open-source Platform as a Service. Deploy means make the app ready to run. Update the app, change the number of running copies and read its logs and health information.

Theory

Platform as a Service (PaaS) gives you a place to run your application. You provide the code and settings. The platform handles tasks such as building and starting the app.

The runtime is the software needed to run your code, such as Node.js. Logs are records that help you see what the app did and why something failed.

Dokku is a free, open-source, Heroku-style PaaS that runs on one Linux server and uses Docker containers.

cloud kitchen

With IaaS (Infrastructure as a Service) you rent an empty kitchen – you buy the stove, gas and utensils yourself. With PaaS you rent a fully equipped kitchen with staff: you only hand over your recipe (code) and say "make it less spicy" (config). The kitchen cooks it, serves it, and adds more cooks when there is a rush (scaling).

sequenceDiagram
    participant Dev as Developer (git)
    participant D as Dokku
    participant B as Buildpack (herokuish)
    participant C as Containers web.1..n
    participant N as nginx router
    Dev->>D: git push dokku main
    D->>B: detect language (package.json → Node.js)
    B-->>D: build image (install runtime + deps)
    D->>C: release & start (Procfile: web)
    D->>C: zero-downtime checks (CHECKS /health)
    D->>N: route notes-app.paas.local → containers
    Dev->>N: HTTP request
    N->>C: load-balance across web processes
PaaS idea Dokku command / file
Create an app dokku apps:create notes-app
Deploy git push dokku main
Find the language automatically The buildpack reads package.json (Node.js), requirements.txt (Python)…
How to start the app Procfile → web: node app.js
Settings (12-factor) dokku config:set notes-app KEY=value
Scaling dokku ps:scale notes-app web=3
Logs dokku logs notes-app
Health / zero-downtime CHECKS file, dokku ps:report, dokku checks:report
Releases Every push creates a new, unchangeable release
Key point

IaaS = you manage the OS (Operating System) and runtime. PaaS = you manage only code and config; the platform builds, runs, scales and routes. The Procfile says how to start the app; config vars keep secrets and settings out of the code (the 12-factor app rule).

Requirements

  • A Linux server with Dokku installed (dokku version)
  • A sample Node.js app: package.json, app.js, Procfile, CHECKS
  • git

Program – app.js

const express = require('express');
const app = express();
const PORT = process.env.PORT || 5000;
const VERSION = 'v1';
const GREETING = process.env.GREETING || 'Hello from Dokku PaaS';

app.get('/', (req, res) => res.send(`<h1>${GREETING}</h1><p>Release ${VERSION}</p>`));
app.get('/health', (req, res) => res.json({ status: 'UP', version: VERSION }));

app.listen(PORT, () => console.log(`notes-app ${VERSION} listening on port ${PORT}`));

What the code does:

  • PORT – the platform tells the app which port to use through an environment variable.
  • VERSION – the release number shown on the page (v1, later v2).
  • GREETING – read from a config var, so we can change the message without changing the code.
  • / – the home page; /health – a small JSON (JavaScript Object Notation) answer the platform uses to check the app is alive.

Procfile – tells the platform how to start the web process:

web: node app.js

Procedure

Step 1 – Check the platform

dokku version

Step 2 – Create the app and its setting

dokku apps:create notes-app
dokku config:set notes-app GREETING="Hello from VirtualLP PaaS"

Creates an empty app called notes-app and stores the greeting as a config var.

Step 3 – Deploy with git

cd notes-app
git init && git add . && git commit -m "first release"
git remote add dokku dokku@localhost:notes-app
git push dokku main
curl -i http://notes-app.paas.local
  • Save the code in git, add Dokku as a "remote", and push – that push is the deployment.
  • curl opens the site and shows the greeting and Release v1.

Step 4 – Release a new version

sed -i 's/v1/v2/' app.js
git commit -am "release v2"
git push dokku main

Change v1 to v2, commit and push again – the page now shows Release v2.

Step 5 – Scale, logs and health

dokku ps:scale notes-app web=3
dokku logs notes-app
curl http://notes-app.paas.local/health
dokku ps:report notes-app
  • ps:scale … web=3 – run 3 copies of the app (more cooks for the rush).
  • logs – see what the app printed.
  • /health – should return {"status":"UP","version":"v2"}.
  • ps:report – shows the running processes.

Step 6 (optional) – Bind a database service

sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
dokku postgres:create notes-db
dokku postgres:link notes-db notes-app
dokku config:show notes-app        # DATABASE_URL=postgres://…
  • Install the Postgres plugin, create a database service called notes-db, and link (bind) it to the app.
  • Dokku automatically adds a DATABASE_URL config var – the app reads it to connect, so no password is written in the code. This is a service binding: the platform plugs a ready-made service into your app, like the kitchen connecting your stall to the shared gas line.

Virtual lab · PaaS (Dokku) · 35 min

Practical 8: FOSS-cloud PaaS – deploy, update, scale and monitor a web app with Dokku

Use Dokku, an open-source Heroku-style PaaS, to deploy a Node.js web app with git push: the platform detects the runtime, builds, releases and routes it. Then set config, roll out a new version, scale the web process, read logs and check health.

Open lab

Output / Observations

Example output for the settings in this lesson:

-----> Node.js app detected
-----> Build succeeded!
-----> Deploying web (count=1)
       All checks successful (web.1)
=====> Application deployed:
       http://notes-app.paas.local

$ curl http://notes-app.paas.local
<h1>Hello from VirtualLP PaaS</h1><p>Release v2</p>

Notice: the language was detected automatically, health checks passed, and the greeting came from the config var, not from the code.

Conclusion

Check that the deployed app opens and shows the new version after an update. Check the number of running web processes, then read the logs and health information. Record the settings you changed.

Viva questions

  1. Differentiate IaaS, PaaS and SaaS (Software as a Service). IaaS gives VMs (Virtual Machines); PaaS gives a managed runtime for your code; SaaS gives a finished application.
  2. What is a buildpack? A set of scripts that detects the language, installs the runtime and dependencies and produces a runnable image.
  3. What is a Procfile? A file that lists process types and their start commands, for example web: node app.js.
  4. Why use environment variables for settings? The same build runs in every environment, and secrets stay out of source control (12-factor).
  5. How does a PaaS achieve zero-downtime deploys? It starts the new release, runs health checks and only then switches the router away from the old containers.
  6. Name open-source PaaS platforms. Dokku, CapRover, Cloud Foundry, OKD/OpenShift.

Practise this topic

Hands-on virtual lab

Apply what you just read in a realistic, guided simulation. Free with a verified account.

Create a free account to track your progress and unlock virtual labs.