Docker Usage Manual in Alxarafe
This document details how to use the Docker-based development environment for Alxarafe.
1. Prerequisites
- Docker installed on the system.
- Docker Compose (usually included in Docker Desktop or as a plugin on Linux).
- Sufficient permissions to run Docker commands (or use of
sudoif necessary).
2. Environment Configuration (.env)
The project includes a file named .env.example in the root, which is already preconfigured to work with the Alxarafe Docker environment.
To start, simply copy this file as .env:
cp .env.example .envIf necessary, you can adapt the key parameters within this file, such as:
- HTTP_PORT: Port to access the web application (default
8081). - MARIADB_PORT: Exposed database port (default
3399). - PHPMYADMIN_PORT: Port for phpMyAdmin (default
9081). - MARIADB_ROOT_PASSWORD: Password for the database root user.
- USER_ID / GROUP_ID: Linux user identifiers to ensure file permissions in the container match the host.
3. Included Services
The environment spins up the following containers:
- alxarafe_nginx: Alpine web server configured to serve the project.
- alxarafe_php: PHP 8.3 interpreter with necessary extensions and Xdebug configured.
- alxarafe_db: MariaDB 10.11 database.
- alxarafe_phpmyadmin: Web interface to manage the database.
- alxarafe_node: Container for frontend dependency management (npm) and asset compilation.
4. Utility Scripts (bin/)
Several scripts have been included in the bin/ folder to simplify container management. These must be run from the project root.
bin/docker_start.sh
Starts all project containers in the background.
bin/run_migrations.sh
Runs the database migrations and seeders inside the PHP container. It is necessary to run this the first time to create default tables and users.
bin/docker_stop.sh
Safely stops all Alxarafe containers without deleting them.
bin/docker_stop_and_remove.sh
Stops and removes the containers. Useful for applying structural changes in docker-compose.yml.
bin/docker_clean_start.sh
Performs a deep clean and restart:
- Deletes
node_modules,vendor,composer.lock, andpackage-lock.json. - Stops and removes current containers.
- Runs
docker system pruneto free up space. - Rebuilds and brings up containers from scratch.
- Automatically opens the application in the default browser.
5. Accessing Services
- Web Application: http://localhost:8081 (or the port defined in
HTTP_PORT). - phpMyAdmin: http://localhost:9081
- Server:
alxarafe_db - User/Pass: Those defined in the
.envfile.
- Server:
6. Useful Docker Commands
If you prefer to use standard commands:
- Start:
docker compose up -d - View logs:
docker compose logs -f - Enter PHP terminal:
docker exec -it alxarafe_php sh - Check status:
docker ps