Skip to content

Deploying a Joomla App

Introduction

Joomla is an open-source content management system built on PHP. Deploying Joomla with a Dockerfile on Klutch.sh delivers reproducible builds, managed secrets, and persistent storage for site assets—all managed from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, and best practices for secure, scalable sites.


Prerequisites

  • A Klutch.sh account (create one)
  • A GitHub repository containing your Joomla code (GitHub is the only supported git source)
  • Docker familiarity and PHP 8.1+ knowledge
  • Database credentials (MySQL/MariaDB)
  • Storage for media, cache, and logs

For platform onboarding, see the Quick Start.


Architecture and ports

  • Serve Joomla over HTTP; set the internal container port to 8080.
  • Run MySQL/MariaDB as a separate Klutch.sh TCP app exposed on port 8000, connecting internally on 3306.
  • Persistent storage is required for images, cache, and recommended for logs.

Repository layout

joomla/
├── images/ # Media uploads (mount as volume)
├── cache/ # Joomla cache (mount as volume)
├── Dockerfile # Must be at repo root for auto-detection
├── configuration.php # Do not commit secrets; use env vars
├── composer.json # If you manage dependencies via Composer
└── README.md

Keep secrets out of Git; store them in Klutch.sh environment variables.


Installation (local) and starter commands

Install dependencies and run locally before pushing to GitHub:

Terminal window
composer install --no-dev --optimize-autoloader
php -S 0.0.0.0:8080 -t .

Optional helper start.sh for portability and Nixpacks fallback:

#!/usr/bin/env bash
set -euo pipefail
php -S 0.0.0.0:8080 -t .

Make it executable with chmod +x start.sh.


Dockerfile for Joomla (production-ready)

Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):

FROM php:8.2-apache
RUN apt-get update && apt-get install -y \
libpng-dev libjpeg-dev libfreetype6-dev libzip-dev libicu-dev libxml2-dev libonig-dev git unzip && \
docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install pdo_mysql gd intl zip opcache && \
a2enmod rewrite && \
rm -rf /var/lib/apt/lists/*
WORKDIR /var/www/html
COPY . /var/www/html
RUN chown -R www-data:www-data /var/www/html
ENV PORT=8080
EXPOSE 8080
CMD ["apache2-foreground"]

Notes:

  • Pin PHP and extension versions to match your Joomla release.
  • Keep writable directories (images, cache) on persistent volumes.

Environment variables (Klutch.sh)

Set these in the Klutch.sh app settings (Secrets tab) before deploying:

  • PORT=8080
  • DB_TYPE=mysqli
  • DB_HOST
  • DB_PORT=3306
  • DB_NAME
  • DB_USER
  • DB_PASSWORD
  • APP_URL=https://example-app.klutch.sh

If you deploy without the Dockerfile and need Nixpacks overrides:

  • NIXPACKS_BUILD_CMD=composer install --no-dev --optimize-autoloader
  • NIXPACKS_START_CMD=php -S 0.0.0.0:8080 -t .
  • NIXPACKS_INSTALL_PKGS="php82 php82Extensions.pdo_mysql php82Extensions.intl php82Extensions.gd php82Extensions.zip"

These keep Joomla compatible with Nixpacks defaults when a Dockerfile is absent.


Attach persistent volumes

In Klutch.sh storage settings, add mount paths and sizes (no names required):

  • /var/www/html/images — media uploads.
  • /var/www/html/cache — Joomla cache.
  • /var/www/html/logs — optional logs.

Ensure these paths are writable inside the container.


Deploy Joomla on Klutch.sh (Dockerfile workflow)

  1. Push your repository (with the Dockerfile at the root) to GitHub.
  2. Open klutch.sh/app, create a project, and add an app.
  1. Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
  2. Choose HTTP traffic for Joomla.
  3. Set the internal port to 8080.
  4. Add the environment variables above (database settings, app URL, and any NIXPACKS_* overrides if you temporarily deploy without the Dockerfile).
  5. Attach persistent volumes for /var/www/html/images and /var/www/html/cache (and /var/www/html/logs if used), choosing sizes that match your media and cache needs.
  6. Deploy. Your Joomla site will be reachable at https://example-app.klutch.sh; attach a custom domain if desired.

For MySQL/MariaDB on Klutch.sh, create a separate TCP app, expose it on port 8000, and point DB_HOST to that endpoint (internal port 3306).


Health checks and production tips

  • Add a lightweight status page or reuse an existing route for health monitoring.
  • Enforce HTTPS at the edge; forward HTTP to port 8080 internally.
  • Keep dependencies pinned and update intentionally to avoid regressions.
  • Monitor volume usage for uploads/cache and resize before they fill.
  • Back up your database and media regularly; do not rely on container filesystems for durability.

Joomla on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and ports set to 8080 for the app (8000 externally for TCP databases), you can deliver a reliable CMS experience without extra YAML or workflow overhead.