From 14dd5b9b6d2d48590b23578536a87d8f6d7eddea Mon Sep 17 00:00:00 2001 From: Gaetano Castaldo Date: Sun, 22 Mar 2026 09:36:11 +0100 Subject: [PATCH 1/2] Add Docker setup (PHP 7.4 + Apache + MySQL 8.0) Adds a self-contained Docker setup to run VTENext CE locally for development and testing. Stack: - PHP 7.4 + Apache (Debian Bullseye) - MySQL 8.0 - phpMyAdmin (optional, --profile tools) Features: - All required PHP extensions pre-installed (curl, imap, gd, bcmath, mbstring, zip, pdo_mysql, mysqli, intl, opcache, apcu, sockets) - Automatic patch for check_db_utf8_support() static method bug - config.db.php written from environment variables at startup - Named volumes for data persistence across restarts - Configurable via .env file Usage: cp docker/.env.example docker/.env docker compose -f docker/docker-compose.yml up -d --build # open http://localhost:8080/install.php Docker Hub: https://hub.docker.com/r/gaetano88/vtenext-ce --- docker/.env.example | 19 ++++++++ docker/Dockerfile | 100 ++++++++++++++++++++++++++++++++++++++ docker/README.md | 86 ++++++++++++++++++++++++++++++++ docker/docker-compose.yml | 85 ++++++++++++++++++++++++++++++++ docker/entrypoint.sh | 51 +++++++++++++++++++ docker/mysql.cnf | 7 +++ docker/php.ini | 25 ++++++++++ docker/vhost.conf | 13 +++++ 8 files changed, 386 insertions(+) create mode 100644 docker/.env.example create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100644 docker/docker-compose.yml create mode 100644 docker/entrypoint.sh create mode 100644 docker/mysql.cnf create mode 100644 docker/php.ini create mode 100644 docker/vhost.conf diff --git a/docker/.env.example b/docker/.env.example new file mode 100644 index 00000000..d38b234d --- /dev/null +++ b/docker/.env.example @@ -0,0 +1,19 @@ +# VTENext Docker — variabili d'ambiente +# Copia in .env e modifica i valori + +APP_PORT=8080 + +DB_ROOT_PASSWORD=root +DB_NAME=vtenext +DB_USER=vtenext +DB_PASSWORD=vtenext +DB_PORT_EXPOSED=3306 + +# Credenziali admin VTENext (usate al primo avvio) +VTENEXT_ADMIN_PASS=admin +VTENEXT_ADMIN_EMAIL=admin@vtenext.local +VTENEXT_USER_PASS=user +VTENEXT_USER_EMAIL=user@vtenext.local + +# phpMyAdmin (accessibile solo con: docker compose --profile tools up) +PMA_PORT=8081 diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..43801ebd --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,100 @@ +FROM php:7.4-apache-bullseye + +LABEL maintainer="Castaldo Solutions " +LABEL description="VTENext CE - Dockerized for local development and testing" +LABEL source="https://github.com/VTECRM/vtenext" + +# System dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + unzip \ + libpng-dev \ + libjpeg62-turbo-dev \ + libfreetype6-dev \ + libxml2-dev \ + libzip-dev \ + libicu-dev \ + libc-client-dev \ + libkrb5-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libssl-dev \ + && rm -rf /var/lib/apt/lists/* + +# PHP extensions required by VTENext +RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && docker-php-ext-install -j$(nproc) \ + curl \ + imap \ + xml \ + gd \ + bcmath \ + mbstring \ + zip \ + pdo \ + pdo_mysql \ + mysqli \ + intl \ + opcache \ + sockets + +# Suggested: APCu for cache +RUN pecl install apcu && docker-php-ext-enable apcu + +# Apache mod_rewrite +RUN a2enmod rewrite + +# Composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +# Clone VTENext from GitHub +ARG VTENEXT_BRANCH=main +RUN cd / \ + && rm -rf /var/www/html \ + && git clone --depth=1 --branch=${VTENEXT_BRANCH} \ + https://github.com/VTECRM/vtenext.git /var/www/html \ + && rm -rf /var/www/html/.git + +# Install Composer dependencies +WORKDIR /var/www/html +RUN composer install --no-dev --optimize-autoloader --no-interaction + +# Fix: check_db_utf8_support() called as global but defined inside Installation_Utils class +# https://github.com/VTECRM/vtenext/issues +RUN php -r "\ +\$f = '/var/www/html/include/install/resources/utils.php'; \ +\$c = file_get_contents(\$f); \ +\$c = str_replace('check_db_utf8_support(\$conn)', 'self::check_db_utf8_support(\$conn)', \$c); \ +\$c = str_replace('function self::check_db_utf8_support', 'function check_db_utf8_support', \$c); \ +file_put_contents(\$f, \$c); \ +echo 'Patched utils.php' . PHP_EOL; \ +" + +# PHP configuration +COPY php.ini /usr/local/etc/php/conf.d/vtenext.ini + +# Apache VirtualHost +COPY vhost.conf /etc/apache2/sites-available/000-default.conf + +# Permissions +RUN chown -R www-data:www-data /var/www/html \ + && find /var/www/html -type d -exec chmod 755 {} \; \ + && find /var/www/html -type f -exec chmod 644 {} \; + +# Writable directories required by VTENext +RUN chmod -R 775 \ + /var/www/html/cache \ + /var/www/html/logs \ + /var/www/html/upload \ + /var/www/html/storage \ + 2>/dev/null || true + +EXPOSE 80 + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["apache2-foreground"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..018b598c --- /dev/null +++ b/docker/README.md @@ -0,0 +1,86 @@ +# VTENext CE — Docker Setup + +Setup Docker per eseguire [VTENext CE](https://github.com/VTECRM/vtenext) in locale per sviluppo e testing. + +## Stack + +| Servizio | Immagine | Porta default | +|----------|----------|---------------| +| VTENext (PHP 8.1 + Apache) | build locale | 8080 | +| MySQL 8.0 | `mysql:8.0` | 3306 | +| phpMyAdmin *(opzionale)* | `phpmyadmin:latest` | 8081 | + +## Avvio rapido + +```bash +# 1. Clona questo repo o copia la cartella docker/ +cd mcp/vtenext/docker + +# 2. Configura le variabili d'ambiente +cp .env.example .env + +# 3. Build e avvio +docker compose up -d --build + +# 4. Apri il wizard di installazione +open http://localhost:8080 +``` + +Durante il wizard inserisci: + +| Campo | Valore | +|-------|--------| +| DB Host | `db` | +| DB Name | `vtenext` | +| DB User | `vtenext` | +| DB Password | `vtenext` | + +> La prima build richiede qualche minuto — deve clonare il repo GitHub e installare le dipendenze Composer. + +## phpMyAdmin (opzionale) + +```bash +docker compose --profile tools up -d +# Apri http://localhost:8081 +``` + +## Comandi utili + +```bash +# Logs in tempo reale +docker compose logs -f vtenext + +# Shell nel container +docker exec -it vtenext_app bash + +# Ricrea tutto da zero (attenzione: cancella il DB) +docker compose down -v && docker compose up -d --build + +# Stop senza cancellare i dati +docker compose stop +``` + +## Struttura file + +``` +docker/ +├── Dockerfile # PHP 8.1 + Apache + estensioni VTENext +├── docker-compose.yml # Orchestrazione servizi +├── php.ini # Impostazioni PHP richieste da VTENext +├── vhost.conf # VirtualHost Apache +├── mysql.cnf # Configurazione MySQL (utf8mb4, native auth) +├── entrypoint.sh # Script di avvio (crea dir, fix permessi) +├── .env.example # Template variabili d'ambiente +└── README.md # Questo file +``` + +## Estensioni PHP installate + +`curl` · `imap` · `xml` · `gd` · `bcmath` · `mbstring` · `zip` · `pdo_mysql` · `mysqli` · `intl` · `opcache` · `apcu` + +## Note + +- Il sorgente VTENext viene clonato da `https://github.com/VTECRM/vtenext` al momento della build +- Per usare un branch/tag specifico: `docker compose build --build-arg VTENEXT_BRANCH=` +- I dati sono persistenti nei volumi Docker — sopravvivono ai restart +- Per un ambiente di produzione: aggiungi HTTPS via reverse proxy (Nginx + Let's Encrypt) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 00000000..1fba484b --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,85 @@ +name: vtenext + +services: + + vtenext: + build: + context: . + dockerfile: Dockerfile + args: + VTENEXT_BRANCH: main + image: vtenext-ce + container_name: vtenext_app + restart: unless-stopped + ports: + - "${APP_PORT:-8080}:80" + environment: + DB_HOST: db + DB_PORT: 3306 + DB_NAME: ${DB_NAME:-vtenext} + DB_USER: ${DB_USER:-vtenext} + DB_PASSWORD: ${DB_PASSWORD:-vtenext} + VTENEXT_ADMIN_PASS: ${VTENEXT_ADMIN_PASS:-admin} + VTENEXT_ADMIN_EMAIL: ${VTENEXT_ADMIN_EMAIL:-admin@vtenext.local} + VTENEXT_USER_PASS: ${VTENEXT_USER_PASS:-user} + VTENEXT_USER_EMAIL: ${VTENEXT_USER_EMAIL:-user@vtenext.local} + volumes: + - vtenext_upload:/var/www/html/upload + - vtenext_storage:/var/www/html/storage + - vtenext_logs:/var/www/html/logs + depends_on: + db: + condition: service_healthy + networks: + - appnet + + db: + image: mysql:8.0 + container_name: vtenext_db + restart: unless-stopped + environment: + MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-root} + MYSQL_DATABASE: ${DB_NAME:-vtenext} + MYSQL_USER: ${DB_USER:-vtenext} + MYSQL_PASSWORD: ${DB_PASSWORD:-vtenext} + ports: + - "${DB_PORT_EXPOSED:-3306}:3306" + volumes: + - vtenext_db_data:/var/lib/mysql + - ./mysql.cnf:/etc/mysql/conf.d/vtenext.cnf:ro + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 30s + networks: + - appnet + + pma: + image: phpmyadmin:latest + container_name: vtenext_pma + restart: unless-stopped + ports: + - "${PMA_PORT:-8081}:80" + environment: + PMA_HOST: db + PMA_USER: ${DB_USER:-vtenext} + PMA_PASSWORD: ${DB_PASSWORD:-vtenext} + UPLOAD_LIMIT: 128M + depends_on: + - db + networks: + - appnet + profiles: + - tools + +volumes: + vtenext_db_data: + vtenext_upload: + vtenext_storage: + vtenext_logs: + +networks: + appnet: + driver: bridge diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 00000000..faf58153 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,51 @@ +#!/bin/bash +set -e + +# Ensure writable directories exist +mkdir -p /var/www/html/cache \ + /var/www/html/logs \ + /var/www/html/upload \ + /var/www/html/storage + +chown -R www-data:www-data \ + /var/www/html/cache \ + /var/www/html/logs \ + /var/www/html/upload \ + /var/www/html/storage + +chmod -R 775 \ + /var/www/html/cache \ + /var/www/html/logs \ + /var/www/html/upload \ + /var/www/html/storage + +# Copy .htaccess if not present +if [ -f /var/www/html/.htaccess.txt ] && [ ! -f /var/www/html/.htaccess ]; then + cp /var/www/html/.htaccess.txt /var/www/html/.htaccess +fi + +# Write config.db.php from environment variables if still contains placeholders +if grep -q '_DBC_TYPE_' /var/www/html/config.db.php 2>/dev/null; then + echo "Writing config.db.php from environment variables..." + cat > /var/www/html/config.db.php << EOF + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + + ErrorLog ${APACHE_LOG_DIR}/vtenext_error.log + CustomLog ${APACHE_LOG_DIR}/vtenext_access.log combined + From e70468fe6546b923494c898515887c35ecdc806a Mon Sep 17 00:00:00 2001 From: Gaetano Castaldo Date: Sun, 22 Mar 2026 09:36:35 +0100 Subject: [PATCH 2/2] Remove maintainer label from Dockerfile --- docker/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 43801ebd..3f9d35b7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,5 @@ FROM php:7.4-apache-bullseye -LABEL maintainer="Castaldo Solutions " LABEL description="VTENext CE - Dockerized for local development and testing" LABEL source="https://github.com/VTECRM/vtenext"