Skip to content

Docker

The project ships with a Docker setup for local development. It gives you PHP, MySQL and phpMyAdmin without installing anything on your machine.

Services

ServiceContainer nameURL / HostNotes
approolith-apphttp://localhost:8080PHP 8.2 + Apache
dbroolith-dblocalhost:3306 (host db)MySQL 8.0
phpmyadminroolith-phpmyadminhttp://localhost:8081MySQL web client

Database credentials:

KeyValue
hostdb
databaseroolith_cms
userroot
passwordroot

A second user roolith / secret also exists with full access to roolith_cms.

Requirements

  • Docker Desktop (or Docker Engine + Compose plugin) installed and running.

First Run

From the project root:

bash
docker compose up -d --build

This builds the PHP/Apache image, starts all 3 services and creates the roolith_cms database automatically. First run takes a few minutes while Docker downloads the images.

Verify everything is running:

bash
docker compose ps

Then open:

  • App: http://localhost:8080
  • phpMyAdmin: http://localhost:8081

App Database Configuration

When you enable the database in config/config.php, use the service name db as host, not localhost:

php
"database" => [
    "host" => "db",
    "name" => "roolith_cms",
    "user" => "root",
    "pass" => "root",
],

Regular Development

Your project folder is mounted into the container, so PHP code changes are visible immediately - just refresh the browser. No rebuild needed.

Daily commands (run from the project root):

bash
docker compose up -d        # start
docker compose stop         # stop (keeps containers)
docker compose down         # stop and remove containers (keeps DB data)
docker compose ps           # status
docker compose logs -f app  # follow app logs
docker compose logs -f db   # follow mysql logs

If you edit the Dockerfile, rebuild:

bash
docker compose up -d --build

Container Access

bash
docker compose exec app bash              # shell into the PHP container
docker compose exec app php roolith generate controller DemoController
docker compose exec db mysql -uroot -proot roolith_cms

Composer can be run on the host if installed, or inside the container:

bash
docker compose exec app composer install

Data Persistence

MySQL data lives in the db_data Docker volume.

  • docker compose down keeps the data.
  • docker compose down -v removes the volume and wipes all database data.

Troubleshooting

Port 3306 already in use - if you run a local MySQL, change the db port mapping in docker-compose.yml to e.g. 3307:3306 and run docker compose up -d.

Port 8080 or 8081 already in use - change the left side of the port mapping for app or phpmyadmin in docker-compose.yml.

phpMyAdmin shows a connection error right after startup - MySQL takes a few seconds to boot on first run. Wait a moment and reload.

Released under the MIT License.