Skip to content

Commit 5a6bf8a

Browse files
Pending changes exported from your codespace
1 parent 2986028 commit 5a6bf8a

File tree

6 files changed

+270
-0
lines changed

6 files changed

+270
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Start from the official PHP 8.2 image with Apache
2+
FROM php:8.2-apache
3+
4+
# Install system dependencies, Node.js, Composer, and Cypress dependencies
5+
RUN apt-get update && apt-get install -y \
6+
# System tools and git
7+
git \
8+
unzip \
9+
curl \
10+
sudo \
11+
# PHP extensions dependencies
12+
libpng-dev \
13+
libonig-dev \
14+
libxml2-dev \
15+
libzip-dev \
16+
# MySQL client AND server
17+
default-mysql-client \
18+
default-mysql-server \
19+
# Cypress dependencies
20+
xvfb \
21+
libgtk2.0-0 \
22+
libgtk-3-0 \
23+
libgbm-dev \
24+
libnotify-dev \
25+
libgconf-2-4 \
26+
libnss3 \
27+
libxss1 \
28+
libasound2 \
29+
libxtst6 \
30+
xauth \
31+
libldap2-dev \
32+
libgd-dev \
33+
&& \
34+
# Install the required PHP extensions for Zip and MySQL
35+
docker-php-ext-install zip mysqli gd ldap && \
36+
# Install Node.js (LTS version)
37+
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
38+
apt-get install -y nodejs && \
39+
# Install Composer globally
40+
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
41+
# Install Xdebug
42+
pecl install xdebug && \
43+
# Clean up apt cache to reduce image size
44+
apt-get clean && rm -rf /var/lib/apt/lists/*
45+
46+
# After installing everything
47+
RUN sed -i 's|/var/www/html|/workspaces/joomla-cms|g' /etc/apache2/sites-available/000-default.conf \
48+
&& sed -i 's|/var/www/html|/workspaces/joomla-cms|g' /etc/apache2/apache2.conf
49+
50+
# Enable Apache's rewrite module and set the ServerName to prevent warnings
51+
RUN a2enmod rewrite \
52+
&& echo "ServerName localhost" >> /etc/apache2/apache2.conf
53+
54+
# Create a custom PHP configuration file to enable file uploads
55+
RUN echo "upload_tmp_dir = /tmp" > /usr/local/etc/php/conf.d/custom-php.ini && \
56+
echo "post_max_size = 64M" >> /usr/local/etc/php/conf.d/custom-php.ini && \
57+
echo "upload_max_filesize = 64M" >> /usr/local/etc/php/conf.d/custom-php.ini

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "Joomla Dev Environment",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspaces/joomla-cms",
6+
"features": {
7+
"ghcr.io/devcontainers/features/desktop-lite:1": {}
8+
},
9+
"portsAttributes": {
10+
"80" : {
11+
"label": "Web Server (Joomla & phpmyadmin)",
12+
"onAutoForward": "silent"
13+
},
14+
"6080": {
15+
"label": "Cypress GUI",
16+
"onAutoForward": "silent"
17+
}
18+
},
19+
"postCreateCommand": "bash ./.devcontainer/post-create.sh",
20+
"customizations": {
21+
"vscode": {
22+
"extensions": [
23+
"xdebug.php-debug",
24+
"bmewburn.vscode-intelephense-client",
25+
"esbenp.prettier-vscode"
26+
]
27+
}
28+
},
29+
"remoteUser": "root"
30+
}

.devcontainer/docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
services:
2+
app:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
volumes:
7+
- ..:/workspaces/joomla-cms:cached
8+
- ./xdebug.ini:/usr/local/etc/php/conf.d/99-xdebug.ini
9+
ports:
10+
- "80:80"
11+
- "3306:3306"
12+
- "6080:6080"
13+
command: sleep infinity
14+
15+
mysql:
16+
image: mysql:8.0
17+
command: --default-authentication-plugin=mysql_native_password
18+
restart: unless-stopped
19+
environment:
20+
MYSQL_ROOT_PASSWORD: root
21+
MYSQL_DATABASE: test_joomla
22+
MYSQL_USER: joomla_ut
23+
MYSQL_PASSWORD: joomla_ut
24+
volumes:
25+
- "mysql-data:/var/lib/mysql"
26+
27+
volumes:
28+
mysql-data:

.devcontainer/post-create.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/bin/bash
2+
3+
# Exit immediately if a command exits with a non-zero status.
4+
set -e
5+
6+
echo "--- Starting Joomla Core Post-Creation Setup ---"
7+
8+
# Configuration variables
9+
DB_NAME="test_joomla"
10+
DB_USER="joomla_ut"
11+
DB_PASS="joomla_ut"
12+
ADMIN_USER="ci-admin"
13+
ADMIN_REAL_NAME="john doe"
14+
ADMIN_PASS="joomla-17082005"
15+
ADMIN_EMAIL="admin@example.org"
16+
17+
# For core development, the Joomla root IS the workspace root.
18+
JOOMLA_ROOT="/workspaces/joomla-cms"
19+
20+
# Allow git commands to run safely in the container
21+
git config --global --add safe.directory "$JOOMLA_ROOT"
22+
23+
# --- 1. Wait for MariaDB Service ---
24+
echo "--> Waiting for MariaDB to become available..."
25+
while ! mysqladmin ping -h"mysql" --silent; do
26+
sleep 1
27+
done
28+
echo "✅ MariaDB is ready."
29+
30+
# --- 2. Install Core Dependencies ---
31+
echo "--> Installing Composer and NPM dependencies..."
32+
# We are already in the JOOMLA_ROOT, no need to cd
33+
composer install
34+
npm install
35+
echo "✅ Dependencies installed."
36+
37+
# --- 3. Install Joomla from Repository Source ---
38+
echo "--> Installing Joomla using the local repository source..."
39+
40+
rm -f configuration.php
41+
42+
php installation/joomla.php install \
43+
--site-name="Joomla Core Dev" \
44+
--admin-user="$ADMIN_REAL_NAME" \
45+
--admin-username="$ADMIN_USER" \
46+
--admin-password="$ADMIN_PASS" \
47+
--admin-email="$ADMIN_EMAIL" \
48+
--db-type="mysqli" \
49+
--db-host="mysql" \
50+
--db-name="$DB_NAME" \
51+
--db-user="$DB_USER" \
52+
--db-pass="$DB_PASS" \
53+
--db-prefix="jos_" \
54+
--db-encryption="0" \
55+
--public-folder=""
56+
echo "✅ Joomla installed."
57+
58+
# --- 4. Configure Joomla for Development ---
59+
echo "--> Applying development settings..."
60+
# Enable debug mode and maximum error reporting for easier troubleshooting.
61+
php cli/joomla.php config:set debug=true
62+
php cli/joomla.php config:set error_reporting=maximum
63+
echo "✅ Development settings applied."
64+
65+
# --- 5. Install and Configure phpMyAdmin ---
66+
PMA_ROOT="${JOOMLA_ROOT}/phpmyadmin"
67+
echo "--> Downloading phpMyAdmin into $PMA_ROOT..."
68+
PMA_VERSION=5.2.2
69+
mkdir -p $PMA_ROOT
70+
curl -o /tmp/phpmyadmin.tar.gz https://files.phpmyadmin.net/phpMyAdmin/${PMA_VERSION}/phpMyAdmin-${PMA_VERSION}-all-languages.tar.gz
71+
tar xf /tmp/phpmyadmin.tar.gz --strip-components=1 -C $PMA_ROOT
72+
rm /tmp/phpmyadmin.tar.gz
73+
cp $PMA_ROOT/config.sample.inc.php $PMA_ROOT/config.inc.php
74+
sed -i "/\['AllowNoPassword'\] = false/a \$cfg['Servers'][\$i]['host'] = 'mysql';" $PMA_ROOT/config.inc.php
75+
76+
# --- 6. Apply Codespaces Host Fix ---
77+
# This ensures Joomla generates correct URLs when accessed through the forwarded port.
78+
echo "--> Applying Codespaces URL fix..."
79+
cat > "$JOOMLA_ROOT/fix.php" << 'EOF'
80+
<?php
81+
// Fix for incorrect host when running behind the Codespaces reverse proxy.
82+
if (isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] === 'localhost:80') {
83+
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
84+
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
85+
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
86+
}
87+
}
88+
EOF
89+
90+
echo "--> Ignoring local changes..."
91+
# For TRACKED files, tell Git to stop watching them for changes
92+
git update-index --assume-unchanged "index.php"
93+
git update-index --assume-unchanged "administrator/index.php"
94+
git update-index --assume-unchanged "package-lock.json"
95+
96+
# For NEW UNTRACKED files, add them to the local exclude file
97+
echo "cypress.config.js" >> ".git/info/exclude"
98+
echo "fix.php" >> ".git/info/exclude"
99+
echo "administrator/fix.php" >> ".git/info/exclude"
100+
echo "codespace-details.txt" >> ".git/info/exclude"
101+
echo "welcome-message.txt" >> ".git/info/exclude"
102+
103+
# --- 7. Finalize Permissions and Testing Tools ---
104+
echo "--> Setting up file permissions and Cypress..."
105+
# Ensure Cypress is executable and owned by the web server user
106+
chmod +x ./node_modules/.bin/cypress
107+
npx cypress install
108+
cp cypress.config.dist.mjs cypress.config.js
109+
110+
# Set correct ownership for all web files to prevent permission errors
111+
chown -R www-data:www-data $JOOMLA_ROOT
112+
113+
# Restart Apache to apply all changes
114+
echo '<Directory /workspaces/joomla-cms>
115+
AllowOverride All
116+
Require all granted
117+
</Directory>' | sudo tee -a /etc/apache2/apache2.conf
118+
service apache2 restart
119+
echo "✅ Environment finalized."
120+
121+
# --- 8. Display Setup Details ---
122+
# Save the details to a file for easy reference.
123+
DETAILS_FILE="${JOOMLA_ROOT}/codespace-details.txt"
124+
{
125+
echo ""
126+
echo "---"
127+
echo "🚀 Joomla Core development environment is ready! 🚀"
128+
echo ""
129+
echo "This information has been saved to codespace-details.txt"
130+
echo ""
131+
echo "Joomla Admin Login:"
132+
echo " URL: Open the 'Ports' tab, find the 'Web Server' (80), and click the Globe icon. Then add /administrator"
133+
echo " Username: $ADMIN_USER"
134+
echo " Password: $ADMIN_PASS"
135+
echo ""
136+
echo "phpMyAdmin Login:"
137+
echo " URL: Open the 'Web Server' port and add /phpmyadmin"
138+
echo " Username: $DB_USER"
139+
echo " Password: $DB_PASS"
140+
echo ""
141+
echo "Cypress E2E Testing:"
142+
echo " Run interactive tests: npx cypress open"
143+
echo " Run headless tests: npx cypress run"
144+
echo ""
145+
echo "Xdebug for PHP Debugging:"
146+
echo " Xdebug is pre-configured on port 9003. Use the 'Run and Debug' panel in VS Code and select 'Listen for Xdebug'."
147+
echo "---"
148+
} | tee "$DETAILS_FILE"

.devcontainer/xdebug.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[xdebug]
2+
zend_extension=xdebug
3+
xdebug.mode=debug
4+
xdebug.start_with_request=yes
5+
xdebug.client_port=9003
6+
xdebug.client_host=localhost

info.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php phpinfo(); ?>

0 commit comments

Comments
 (0)