Skip to main content

Overview

CompuTécnicos uses Docker for containerized deployment, providing a consistent environment across development and production. The application stack includes:
  • App Container: PHP 8.2 + Apache web server
  • Database Container: MySQL 8.0 with persistent storage
  • phpMyAdmin: Database management tool (development only)

Prerequisites

Before deploying with Docker, ensure you have:
  • Docker Desktop installed
  • Docker Compose (included with Docker Desktop)
  • Git for cloning the repository
  • Basic knowledge of command line operations

Quick Start

1

Clone the Repository

Clone the CompuTécnicos repository to your server or local machine:
git clone <repository-url> computecnicos
cd computecnicos
2

Configure Environment Variables

Create your environment configuration file:
cp .env.example .env
Edit the .env file with your preferred text editor:
nano .env
The .env.example file comes with pre-configured defaults suitable for development.
3

Build and Start Services

Build the Docker images and start all services:
docker-compose up -d --build
The -d flag runs containers in detached mode (background), and --build ensures images are rebuilt with the latest code.
4

Verify Deployment

Check that all services are running:
docker-compose ps
View application logs:
docker-compose logs -f app
Press Ctrl+C to exit log viewing.
5

Access the Application

Open your browser and navigate to:

Environment Variables

Configure these variables in your .env file:

Application Ports

VariableDefaultDescription
APP_PORT8080Port for accessing the web application
DB_PORT3306External port for MySQL database
PMA_PORT8081Port for phpMyAdmin interface

Database Configuration

VariableDefaultDescription
DB_NAMEcomputecnicosDatabase name
DB_USERcomputecnicos_userApplication database user
DB_PASScomputecnicos_secretApplication database password
MYSQL_ROOT_PASSWORDroot_secretMySQL root password
Change all default passwords before deploying to production!

Payment Integration

VariableDefaultDescription
PAYPAL_CLIENT_ID-PayPal API client ID
PAYPAL_CLIENT_SECRET-PayPal API secret key
PAYPAL_ENVIRONMENTsandboxPayPal environment (sandbox or live)

Electronic Invoicing

VariableDefaultDescription
FE_PROVIDERalegraInvoicing provider (alegra or siigo)
FE_SIMULATEtrueEnable simulation mode for testing
ALEGRA_TOKEN-Alegra API authentication token
ALEGRA_EMAIL-Alegra account email
SIIGO_CLIENT_ID-Siigo OAuth client ID
SIIGO_CLIENT_SECRET-Siigo OAuth client secret
SIIGO_USERNAME-Siigo account username
SIIGO_PASSWORD-Siigo account password

Docker Commands

Service Management

# Start all services in background
docker-compose up -d

# Start with logs visible
docker-compose up

Development Mode

Enable phpMyAdmin for database management:
docker-compose --profile dev up -d
phpMyAdmin will be accessible at http://localhost:8081

Monitoring and Logs

# Check service status
docker-compose ps

Container Access

# Open bash shell in app container
docker-compose exec app bash

# Execute PHP script
docker-compose exec app php scripts/seed_random_products.php

# Fix file permissions
docker-compose exec app chown -R www-data:www-data /var/www/html/uploads
docker-compose exec app chmod -R 775 /var/www/html/uploads

Database Management

Manual SQL Import

Import SQL files directly into the database:
docker-compose exec -T db mysql -u root -proot_secret computecnicos < database/computecnicos_full.sql
The -T flag disables pseudo-TTY allocation, which is required for piping input.

Backup and Restore

# Export database with timestamp
docker-compose exec db mysqldump -u root -proot_secret computecnicos > backup_$(date +%Y%m%d).sql

# With specific options
docker-compose exec db mysqldump \
  -u root -proot_secret \
  --single-transaction \
  --quick \
  computecnicos > backup.sql

Docker Architecture

The CompuTécnicos Docker setup consists of:

Dockerfile (Dockerfile:1-93)

Multi-stage build configuration that:
  • Uses PHP 8.2 with Apache as base image
  • Installs required system dependencies and PHP extensions
  • Enables Apache modules: rewrite, headers, expires
  • Configures optimized PHP settings for production
  • Installs Composer for dependency management
  • Creates required directories with proper permissions
  • Sets up custom entrypoint script for initialization
Key PHP Extensions Installed:
  • pdo, pdo_mysql, mysqli - Database connectivity
  • gd - Image processing
  • zip - Archive handling
  • intl - Internationalization
  • mbstring - Multibyte string support
  • opcache - PHP bytecode caching
  • xml - XML processing

Docker Compose (docker-compose.yml:1-105)

Orchestrates three services:
  1. app - PHP/Apache application container
    • Exposes port 8080 (configurable via APP_PORT)
    • Mounts persistent volumes for uploads and logs
    • Depends on healthy database connection
  2. db - MySQL 8.0 database container
    • Exposes port 3306 for external access
    • Auto-imports SQL schema on first run
    • Includes health check for service dependencies
    • Uses persistent volume for data storage
  3. phpmyadmin - Database management interface
    • Only runs when dev profile is active
    • Accessible on port 8081
    • Automatically connects to database

Persistent Volumes

Three volumes ensure data persistence:
  • db_data - MySQL database files
  • uploads_data - User uploaded files
  • app_logs - Application logs

Network

All services communicate through the computecnicos-net bridge network, providing isolation and service discovery.

Troubleshooting

Database Connection Issues

1

Check Container Status

Verify that the database container is healthy:
docker-compose ps
Look for healthy status on the db service.
2

Review Database Logs

Check MySQL logs for errors:
docker-compose logs db
3

Restart Database

Try restarting the database service:
docker-compose restart db
Wait 30 seconds for the health check to pass.
4

Verify Credentials

Ensure environment variables match in both services:
docker-compose exec app env | grep DB_

Permission Errors

If you encounter file permission errors in the uploads directory:
docker-compose exec app chown -R www-data:www-data /var/www/html/uploads
docker-compose exec app chmod -R 775 /var/www/html/uploads
For log directory permissions:
docker-compose exec app chown -R www-data:www-data /var/www/html/logs
docker-compose exec app chmod -R 775 /var/www/html/logs

Port Already in Use

If ports 8080, 3306, or 8081 are already in use:
  1. Edit your .env file
  2. Change the conflicting port variables (APP_PORT, DB_PORT, PMA_PORT)
  3. Restart services: docker-compose up -d

Complete Reset

To rebuild everything from scratch:
This will delete all database data and uploaded files!
# Stop and remove everything
docker-compose down -v

# Remove images
docker-compose rm -f

# Rebuild and start
docker-compose up -d --build

Container Won’t Start

Check detailed error messages:
# View full logs
docker-compose logs app

# Inspect container configuration
docker inspect computecnicos-app

Next Steps

Production Setup

Configure CompuTécnicos for production deployment

Environment Variables

Configure environment variables for your deployment

Build docs developers (and LLMs) love