Owncloud Deployment in Dokku

Seit kurzem benutzen wir Dokku (Dokku-Alt), um schnell und einfach verschiedene Applikationen auf unserem Server zu verteilen. Als Spielprojekt hatte ich mir vorgenommen, Owncloud aufzusetzen. (Hier geht es zum Artikel über Dokku.)

Hier ist eine kurze Anleitung, wie ich vorgegangen bin:

[English version below]

Voraussetzungen

  • Laufende Dokku-Alt Instanz auf einem Server
  • Möglichkeit, neue Git Repositories zu erstellen

Erste Schritte

  • Aktuelle Version von Owncloud laden und in ein leeres lokales Git Repo entpacken
  • Dokku als Git Remote hinzufügen: git remote add deploy dokku@your-dokku-domain.de:owncloud
  • Mit dem Befehl git push deploy master wird Owncloud als App zu Dokku hinzugefügt 
    • In Dokku sollte jetzt eine neue App owncloud installiert werden
    • Auch ohne composer.json sollte Dokku erkennen, dass es sich um ein PHP Projekt handelt
  • Als letzten Schritt der Installation sollte Dokku eine URL ausgeben, über die Owncloud jetzt erreichbar ist
  • Wenn alles funktioniert hat, sollte man einen Hinweis auf fehlende PHP Extensions bekommen, wenn man Owncloud aufruft

Konfiguration

Damit Owncloud funktionieren kann, fehlen noch ein paar Dinge: unter anderem verschiedene Extensions für PHP und eine Datenbank. Dokku macht es einem sehr einfach bei der Konfiguration:

{ "require": { "php": "~5.6.0", "ext-gd": "*", "ext-mbstring": "*" } }
web: vendor/bin/heroku-php-apache2
  • Im Procfile wird explizit angegeben, dass es sich um ein Web-Projekt handelt, das auf PHP basiert und als Webserver Apache2 nutzen soll 
  • In der composer.json werden die benötigten PHP Extensions angeben, die Dokku für Owncloud nutzen soll
  • Zum Schluss die Änderungen mit git push deploy master an Dokku senden und sich freuen, dass Dokku jetzt Apache verwendet und die Extensions hinzufügt :)

Datenbank aufsetzen

  • Mit folgendem Befehl wird eine Datenbank (ich nutze postgresql) für Owncloud erstellt: ssh dokku@your-dokku-domain.de postgresql:create owncloud-database
  • Die neue Datenbank mit der App verknüpfen: ssh dokku@your-dokku-domain.de postgresql:link owncloud owncloud-database
  • Und um die Datenbank für die Konfiguration von Owncloud zu nutzen, bekommt man mit folgendem Befehl die nötigen Infos: ssh dokku@your-dokku-domain.de config owncloud
    • Die Ausgabe sollte in etwa so aussehen: postgres://owncloud:PASSWORD@postgresql:5432/owncloud-database
    • Und setzt sich aus postgres://nutzer:passwort@host zusammen. Wobei /owncloud-database der Name der Datenbank ist

Persistenten Speicher einrichten

Dokku hat die Angewohnheit, mit jedem Deploy (und das macht Dokku bei jedem git push) die Anwendung komplett neu zu erstellen. Das bedeutet im Falle von Owncloud, dass Konfiguration und Dateien verschwinden würden. Damit das nicht passiert, bietet Dokku-Alt sogenannte Volumes an.

  • Neues Volume für genannte Ordner erstellen: ssh dokku@your-dokku-domain.de volume:create owncloud-data-volume /app/data /app/config
  • Volume und App verknüpfen: ssh dokku@your-dokku-domain.de volume:link owncloud owncloud-data-volume

Dadurch behält Owncloud mit jedem Deploy seine Konfiguration und hochgeladene Dateien von Nutzern.

Owncloud konfigurieren

Im letzten Schritt kann man endlich Owncloud selbst konfigurieren und nutzen. Dafür ruft man einfach die von Dokku vergebene Domain auf. 

Wer gern https benutzen möchte, kann über Dokku SSL Zertifikate zuweisen oder selbstsignierte vergeben:  ssh dokku@your-dokku-domain.de ssl:selfsigned owncloud.

Wir freuen uns auf eure Kommentare und Feedback, zum Beispiel auf Twitter!

Owncloud Deployment in Dokku

We are using Dokku (Dokku-Alt) for a few weeks now to deploy applications quickly and easily to our server. As a for-fun project I wanted to deploy Owncloud on this infrastructure.

This is a short tutorial of my approach:

Prerequisites

  • a running Dokku-Alt instance on a server
  • the possibility to create new Git repositories

First steps

  • download the current version of Owncloud and unpack it in an empty Git repository
  • add Dokku as a Git remote: git remote add deploy dokku@your-dokku-domain.de:owncloud
  • the command git push deploy master adds Owncloud as an App to Dokku
    • own cloud should now be installed as a new App in Dokku
    • even without a composer.json Dokku should realise that it is a PHP project
  • As last step of the installation Dokku should display a URL at which Owncloud can now be reached

If everything worked, you should get a notification about missing PHP extensions when you try to access Owncloud.

Configuration

A few things are missing for Owncloud to function properly: the PHP extensions and a database among other things. Dokku makes configuration a breeze:

web: vendor/bin/heroku-php-apache2
{ "require": { "php": "~5.6.0", "ext-gd": "*", "ext-mbstring": "*" } }
  • The Procfile explicitly states, that it is a web project based on PHP and using Apache2 as web server
  • The composer.json lists the required PHP extensions that Dokku should use for Owncloud
  • Finally all changes are sent to Dokku with git push deploy master and you are happy that Dokku now uses Apache and adds the extensions :)

Database setup

  • The following command creates a database (I use postgresql) for Owncloud: ssh dokku@your-dokku-domain.de postgresql:create owncloud-database
  • To link the new database to the App: ssh dokku@your-dokku-domain.de postgresql:link owncloud owncloud-database
  • To use the database for the configuration of Owncloud, you get the necessary information with the following command: ssh dokku@your-dokku-domain.de config owncloud
    • The output should look somewhat like this: postgres://owncloud:PASSWORD@postgresql:5432/owncloud-database
    • Consisting of postgres://nutzer:passwort@host. Where /owncloud-database is the name of the database

Setup of persistent storage

Dokku has the habit to completely recreate the application with every deployment (which Dokku does for each git push). For Owncloud this means, that all configuration and files would disappear. To prevent this from happening, Dokku-Alt offers so-called volumes.

  • Create new volumes for relevant folders: ssh dokku@your-dokku-domain.de volume:create owncloud-data-volume /app/data /app/config
  • Link volumes and App: ssh dokku@your-dokku-domain.de volume:link owncloud owncloud-data-volume

Configured this way, Owncloud keeps its configuration and files uploaded by users with each deployment.

Configuring Owncloud

Finally you can configure and use Owncloud itself. Just go to the URL provided by Dokku.

If you want to use https, you can allocate SSL certificates or create self-signed ones with Dokku: ssh dokku@your-dokku-domain.de ssl:self signed own cloud.

We value your comments and feedback, for example on twitter!