Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROFILE=mysql
45 changes: 26 additions & 19 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Start from the official PHP 8.4 image with Apache
FROM php:8.4-apache-bookworm

# Install system dependencies, Node.js, Composer, and Cypress dependencies
RUN apt-get update && apt-get install -y \
# System tools and git
git \
zstd \
wget \
curl \
sudo \
unzip \
# PHP extensions dependencies
libpng-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
# MySQL client AND server
# MySQL client (il server MySQL gira nel container dedicato)
default-mysql-client \
default-mysql-server \
# PostgreSQL client (il server PostgreSQL gira nel container dedicato)
postgresql-client \
libpq-dev \
# Cypress dependencies
xvfb \
libgtk2.0-0 \
Expand All @@ -29,29 +30,35 @@ RUN apt-get update && apt-get install -y \
libxtst6 \
xauth \
&& \
# Install the required PHP extensions for Zip and MySQL
docker-php-ext-install zip mysqli && \
# Install Node.js (LTS version)
# PHP extensions
docker-php-ext-install zip mysqli pdo pdo_mysql pdo_pgsql pgsql && \
# Node.js LTS
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs && \
# Install Composer globally
# Composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
# Install Xdebug
# Xdebug
pecl install xdebug && \
# Enable Apache's rewrite module and set the ServerName to prevent warnings
a2enmod rewrite && \
docker-php-ext-enable xdebug && \
Comment on lines +40 to +42
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Avoid configuring Xdebug twice to prevent duplicate zend_extension warnings.

pecl install xdebug + docker-php-ext-enable xdebug already creates an ini with zend_extension=xdebug, and post-create.sh adds the same line to 99-xdebug.ini, so Xdebug will be loaded twice. To avoid warnings and version‑dependent issues, either drop zend_extension from 99-xdebug.ini and rely on the auto-generated ini, or skip docker-php-ext-enable and manage Xdebug only via your custom ini.

# Apache
a2enmod rewrite ssl && \
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
# Clean up apt cache to reduce image size
# Cleanup
apt-get clean && rm -rf /var/lib/apt/lists/* && \
# Create a custom PHP configuration file to enable file uploads
# Create the log directory and file with correct permissions for the www-data user
# PHP config
mkdir -p /var/log/ && \
touch /var/log/php_errors.log && \
chown -R www-data:www-data /var/log/ && \
chmod 766 /var/log/php_errors.log && \
echo "upload_tmp_dir = /tmp" > /usr/local/etc/php/conf.d/custom-php.ini && \
echo "post_max_size = 64M" >> /usr/local/etc/php/conf.d/custom-php.ini && \
echo "upload_max_filesize = 64M" >> /usr/local/etc/php/conf.d/custom-php.ini && \
echo "log_errors = On" >> /usr/local/etc/php/conf.d/custom-php.ini && \
echo "upload_tmp_dir = /tmp" > /usr/local/etc/php/conf.d/custom-php.ini && \
echo "post_max_size = 64M" >> /usr/local/etc/php/conf.d/custom-php.ini && \
echo "upload_max_filesize = 64M" >> /usr/local/etc/php/conf.d/custom-php.ini && \
echo "log_errors = On" >> /usr/local/etc/php/conf.d/custom-php.ini && \
echo "error_log = /var/log/php_errors.log" >> /usr/local/etc/php/conf.d/custom-php.ini && \
echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/custom-php.ini
echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/custom-php.ini

# Apache VirtualHost per Joomla
COPY apache-joomla.conf /etc/apache2/sites-available/000-default.conf

EXPOSE 80 443
CMD ["apache2-foreground"]
13 changes: 13 additions & 0 deletions .devcontainer/apache-joomla.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

<Directory /var/www/html>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
52 changes: 23 additions & 29 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,40 @@
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/testcom",

// Per MySQL (default):
"runServices": ["app", "mysql", "mailpit"],
"containerEnv": {
"PROFILE": "mysql"
},

// Per PostgreSQL, sostituisci le due righe sopra con:
// "runServices": ["app", "db_pgsql", "mailpit"],
// "containerEnv": { "PROFILE": "pgsql" },

"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {}
},

"portsAttributes": {
"443" : {
"label": "Web Server (Joomla & phpmyadmin)",
"onAutoForward": "silent"
},
"6080": {
"label": "Cypress GUI",
"onAutoForward": "silent"
},
"8025": {
"label": "Mailpit Web UI",
"onAutoForward": "openPreview"
}
"80": { "label": "Web Server", "onAutoForward": "silent" },
"443": { "label": "Web Server HTTPS", "onAutoForward": "silent" },
"6080": { "label": "Cypress GUI", "onAutoForward": "silent" },
"8025": { "label": "Mailpit", "onAutoForward": "openPreview" },
"9003": { "label": "Xdebug", "onAutoForward": "silent" }
},
"forwardPorts": [80, 443, 6080, 8025],
"forwardPorts": [80, 443, 6080, 8025, 9003],

"postCreateCommand": "bash ./.devcontainer/post-create.sh",

"customizations": {
"vscode": {
"extensions": [
"xdebug.php-debug",
"bmewburn.vscode-intelephense-client",
"esbenp.prettier-vscode"
],
"settings": {
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"log": false
}
]
}
}
"esbenp.prettier-vscode",
"cweijan.vscode-database-client2"
]
}
},
"remoteUser": "root"
Expand Down
51 changes: 49 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
networks:
internal:
name: testcom-internal
driver: bridge

services:
app:
build:
Expand All @@ -6,12 +11,21 @@ services:
volumes:
- ..:/workspaces/testcom:cached
- ./xdebug.ini:/usr/local/etc/php/conf.d/99-xdebug.ini
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Binding xdebug.ini while also rewriting 99-xdebug.ini in post-create.sh can be confusing and redundant.

Because ./xdebug.ini is mounted to /usr/local/etc/php/conf.d/99-xdebug.ini but post-create.sh later regenerates that same file, the bind mount no longer has any effect and creates ambiguity about the real source of truth. Consider either removing the bind mount and relying on the script-generated config, or stopping the script from rewriting 99-xdebug.ini and keeping all configuration in the mounted file instead.

Suggested implementation:

    volumes:
      - ..:/workspaces/testcom:cached
      - joomla-html:/var/www/html

To fully align with the suggestion, verify that post-create.sh is indeed generating /usr/local/etc/php/conf.d/99-xdebug.ini with the desired Xdebug settings. If any configuration currently exists only in ./xdebug.ini, you should migrate those settings into the script-generated file logic in post-create.sh, or into a base template that the script uses.

- joomla-html:/var/www/html
ports:
- "80:80"
- "443:443"
- "3306:3306"
- "6080:6080"
command: sleep infinity
networks:
- internal
depends_on:
mysql:
condition: service_healthy
required: false
db_pgsql:
condition: service_healthy
required: false

mysql:
image: mysql:8.0
Expand All @@ -23,11 +37,44 @@ services:
MYSQL_USER: joomla_ut
MYSQL_PASSWORD: joomla_ut
volumes:
- "mysql-data:/var/lib/mysql"
- mysql-data:/var/lib/mysql
networks:
- internal
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "joomla_ut", "-pjoomla_ut"]
interval: 5s
timeout: 5s
retries: 20
start_period: 15s

db_pgsql:
image: postgres:16
restart: unless-stopped
environment:
POSTGRES_DB: test_joomla
POSTGRES_USER: joomla_ut
POSTGRES_PASSWORD: joomla_ut
volumes:
- db_pgsql_data:/var/lib/postgresql/data
networks:
- internal
healthcheck:
test: ["CMD-SHELL", "pg_isready -U joomla_ut -d test_joomla"]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s

mailpit:
image: axllent/mailpit:latest
restart: unless-stopped
ports:
- "1025:1025"
- "8025:8025"
networks:
- internal

volumes:
mysql-data:
db_pgsql_data:
joomla-html:
Loading
Loading