diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..d4f404006 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,31 @@ +FROM mcr.microsoft.com/devcontainers/php:1-8.2-bookworm +# All necessary PHP dependnencies +RUN apt update && \ + apt install -y \ + libpng-dev libjpeg-dev libfreetype6-dev \ + libldap2-dev \ + build-essential autoconf pkg-config && \ + docker-php-ext-configure gd --with-freetype --with-jpeg && \ + docker-php-ext-install gd mysqli ldap && \ + rm -rf /var/lib/apt/lists/* +# Enable Xdebug +RUN XDEBUG_INI="/usr/local/etc/php/conf.d/xdebug.ini" && \ + mkdir -p "$(dirname "$XDEBUG_INI")" && \ + if ! php -m | grep -qi xdebug; then \ + docker-php-ext-install xdebug; \ + fi && \ + if [ ! -f "$XDEBUG_INI" ]; then \ + echo "xdebug.mode=off" > "$XDEBUG_INI" && \ + echo "xdebug.start_with_request=no" >> "$XDEBUG_INI" && \ + echo "xdebug.client_host=host.docker.internal" >> "$XDEBUG_INI" && \ + echo "xdebug.client_port=9003" >> "$XDEBUG_INI"; \ + else \ + sed -i '/^zend_extension/d' "$XDEBUG_INI"; \ + grep -q "xdebug.mode" "$XDEBUG_INI" || echo "xdebug.mode=off" >> "$XDEBUG_INI"; \ + grep -q "xdebug.start_with_request" "$XDEBUG_INI" || echo "xdebug.start_with_request=no" >> "$XDEBUG_INI"; \ + grep -q "xdebug.client_host" "$XDEBUG_INI" || echo "xdebug.client_host=host.docker.internal" >> "$XDEBUG_INI"; \ + grep -q "xdebug.client_port" "$XDEBUG_INI" || echo "xdebug.client_port=9003" >> "$XDEBUG_INI"; \ + fi + +# Optional: confirm extensions are active for debugging +RUN php -m | grep -E 'mysqli|ldap|gd' diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..6d7cee7b7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,15 @@ +{ + "name": "LibreBooking Dev", + "build": { + "dockerfile": "Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/git-lfs:1": {} + }, + "postCreateCommand": "composer install", + "postStartCommand": "bash .devcontainer/ldap_setup.sh", + "forwardPorts": [ + 8080 + ], + "remoteUser": "root" +} \ No newline at end of file diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100644 index 000000000..e2ed6dd04 --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,6 @@ +# Setup LDAP +mkdir -p plugins/Authentication/Ldap plugins/Authentication/ActiveDirectory +echo " false];" > plugins/Authentication/Ldap/Ldap.config.php +echo " false];" > plugins/Authentication/ActiveDirectory/ActiveDirectory.config.php +# Copy default config to be usable right away for testing +cp config/config.dist.php config/config.php \ No newline at end of file