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
20 changes: 17 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,22 @@ RUN sed -i 's|/var/www/html|/workspaces/joomla-cms|g' /etc/apache2/sites-availab
# Enable Apache's rewrite module and set the ServerName to prevent warnings
RUN a2enmod rewrite \
&& echo "ServerName localhost" >> /etc/apache2/apache2.conf

RUN apt-get update && apt-get install -y ssl-cert && \
a2enmod ssl && \
a2ensite 000-default && \
a2ensite default-ssl && \
sed -i 's|/var/www/html|/workspaces/joomla-cms|g' /etc/apache2/sites-available/default-ssl.conf && \
echo '<Directory /workspaces/joomla-cms>\n Options Indexes FollowSymLinks\n AllowOverride All\n Require all granted\n</Directory>' >> /etc/apache2/sites-available/default-ssl.conf

# Create a custom PHP configuration file to enable file uploads
RUN echo "upload_tmp_dir = /tmp" > /usr/local/etc/php/conf.d/custom-php.ini && \
# Create a custom PHP configuration file to enable file uploads and a log directory
RUN 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 "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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ghcr.io/devcontainers/features/desktop-lite:1": {}
},
"portsAttributes": {
"80" : {
"443" : {
"label": "Web Server (Joomla & phpmyadmin)",
"onAutoForward": "silent"
},
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- ./xdebug.ini:/usr/local/etc/php/conf.d/99-xdebug.ini
ports:
- "80:80"
- "443:443"
- "3306:3306"
- "6080:6080"
command: sleep infinity
Expand Down
11 changes: 5 additions & 6 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ echo "✅ Dependencies installed."

# --- 3. Install Joomla from Repository Source ---
echo "--> Installing Joomla using the local repository source..."
rm -f configuration.php
php installation/joomla.php install \
--site-name="Joomla CMS Test" \
--admin-user="$ADMIN_REAL_NAME" \
Expand Down Expand Up @@ -72,7 +73,7 @@ echo "--> Applying Codespaces URL fix..."
cat > "${JOOMLA_ROOT}/fix.php" << 'EOF'
<?php
// Fix for incorrect host when running behind the Codespaces reverse proxy.
if (isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] === 'localhost:80') {
if (isset($_SERVER['HTTP_HOST']) && str_contains($_SERVER['HTTP_HOST'], 'localhost')) {
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
Expand All @@ -81,7 +82,6 @@ if (isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] === 'localhost:80') {
EOF

# Include fix in both entry points
cp $JOOMLA_ROOT/fix.php $JOOMLA_ROOT/administrator/fix.php
sed -i '2i require_once __DIR__ . "/fix.php";' $JOOMLA_ROOT/index.php
sed -i '2i require_once __DIR__ . "/../fix.php";' $JOOMLA_ROOT/administrator/index.php

Expand All @@ -96,7 +96,6 @@ git update-index --assume-unchanged "tests/System/support/commands/config.mjs"
# For NEW UNTRACKED files, add them to the local exclude file
echo "cypress.config.js" >> ".git/info/exclude"
echo "fix.php" >> ".git/info/exclude"
echo "administrator/fix.php" >> ".git/info/exclude"
echo "phpmyadmin" >> ".git/info/exclude"
echo "codespace-details.txt" >> ".git/info/exclude"

Expand All @@ -107,13 +106,12 @@ sed -i \
-e "/cy.task('deleteRelativePath', 'configuration.php');/d" \
-e "/cy.installJoomla(config);/d" \
tests/System/integration/install/Installation.cy.js
sed -i "s/return cy.task('writeRelativeFile', { path: 'configuration.php', content });/return cy.task('writeRelativeFile', { path: 'configuration.php', content, mode: 0o775 });/" tests/System/support/commands/config.mjs

# Ensure Cypress is executable and owned by the web server user
chmod +x ./node_modules/.bin/cypress
cp cypress.config.dist.mjs cypress.config.js
npx cypress install
sed -i -e "s|baseUrl:.*|baseUrl: 'http://localhost:80',|" -e "s/db_host: 'localhost'/db_host: 'mysql'/g" -e "s/db_user: 'root'/db_user: 'joomla_ut'/g" -e "s/db_password: ''/db_password: 'joomla_ut'/g" cypress.config.js
sed -i -e "s|baseUrl:.*|baseUrl: 'https://localhost',|" -e "s/db_host: 'localhost'/db_host: 'mysql'/g" -e "s/db_user: 'root'/db_user: 'joomla_ut'/g" -e "s/db_password: ''/db_password: 'joomla_ut'/g" cypress.config.js

# Restart Apache to apply all changes
echo '<Directory /workspaces/joomla-cms>
Expand All @@ -126,6 +124,7 @@ service apache2 restart
echo "--> Applying final group ownership and permissions..."
chgrp -R www-data $JOOMLA_ROOT
chmod -R g+rws $JOOMLA_ROOT
chown www-data:www-data configuration.php

echo "✅ Environment finalized."

Expand All @@ -140,7 +139,7 @@ DETAILS_FILE="${JOOMLA_ROOT}/codespace-details.txt"
echo "This information has been saved to codespace-details.txt"
echo ""
echo "Joomla Admin Login:"
echo " URL: Open the 'Ports' tab, find the 'Web Server' (80), and click the Globe icon. Then add /administrator"
echo " URL: Open the 'Ports' tab, find the 'Web Server' (443), and click the Globe icon. Then add /administrator"
echo " Username: $ADMIN_USER"
echo " Password: $ADMIN_PASS"
echo ""
Expand Down
Loading