From 6e45a2361d8fda576403405c90f198e5d34b8d4d Mon Sep 17 00:00:00 2001 From: battye Date: Sat, 17 Dec 2022 10:04:45 +0800 Subject: [PATCH 1/6] [ticket/17086] Add devcontainer configuration for Codespaces PHPBB3-17086 --- .devcontainer/Dockerfile | 20 +++++++++++ .devcontainer/devcontainer.json | 37 ++++++++++++++++++++ .devcontainer/resources/phpbb-config.yml | 38 ++++++++++++++++++++ .devcontainer/resources/setup.sh | 44 ++++++++++++++++++++++++ .devcontainer/resources/xdebug.ini | 10 ++++++ .vscode/launch.json | 18 ++++++++++ .vscode/settings.json | 3 ++ 7 files changed, 170 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/resources/phpbb-config.yml create mode 100644 .devcontainer/resources/setup.sh create mode 100644 .devcontainer/resources/xdebug.ini create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..3d5b94426e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +# Debian version +ARG VARIANT="buster" +FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} + +# Install PHP +RUN apt-get -y update +RUN apt-get -y install php php-xml php-mbstring php-curl php-zip php-xdebug + +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install MySQL +RUN apt-get -y install mysql-server php-mysql + +# Xdebug +ADD resources/xdebug.ini /etc/php/8.1/apache2/conf.d/xdebug.ini + +# Configure Apache +RUN echo "Listen 8080" >> /etc/apache2/ports.conf && \ + a2enmod rewrite \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..33f13337fb --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,37 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/ubuntu +{ + "name": "Ubuntu", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04 + // Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon. + "args": { "VARIANT": "ubuntu-22.04" } + }, + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + "settings": { + // Allow Xdebug to listen to requests from remote (or container) + "remote.localPortHost": "allInterfaces" + }, + //"devPort": {}, + // Specify which VS Code extensions to install (List of IDs) + "extensions": ["xdebug.php-debug"] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [80, 9003], + + // Use 'postCreateCommand' to run commands after the container is created. + "postStartCommand": "bash .devcontainer/resources/setup.sh", + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + "github-cli": "latest" + } +} \ No newline at end of file diff --git a/.devcontainer/resources/phpbb-config.yml b/.devcontainer/resources/phpbb-config.yml new file mode 100644 index 0000000000..414aef02a2 --- /dev/null +++ b/.devcontainer/resources/phpbb-config.yml @@ -0,0 +1,38 @@ +installer: + admin: + name: admin + password: mypassword + email: admin@example.org + + board: + lang: en + name: My Board + description: My amazing new phpBB board + + database: + dbms: mysqli + dbhost: 127.0.0.1 + dbport: 3306 + dbuser: phpbb + dbpasswd: phpbb + dbname: phpbb + table_prefix: phpbb_ + + email: + enabled: false + smtp_delivery : ~ + smtp_host: ~ + smtp_port: ~ + smtp_auth: ~ + smtp_user: ~ + smtp_pass: ~ + + server: + cookie_secure: false + server_protocol: http:// + force_server_vars: false + server_name: localhost + server_port: 80 + script_path: / + + extensions: [] \ No newline at end of file diff --git a/.devcontainer/resources/setup.sh b/.devcontainer/resources/setup.sh new file mode 100644 index 0000000000..a2df6777f5 --- /dev/null +++ b/.devcontainer/resources/setup.sh @@ -0,0 +1,44 @@ +# setup.sh +# Commands to install and configure phpBB + +# Start MySQL +echo "[Codespaces] Start MySQL" +sudo service mysql start + +# Start Apache +echo "[Codespaces] Start Apache" +sudo service apache2 start + +# Add SSH key +echo "[Codespaces] Add SSH key" +echo "$SSH_KEY" > /home/vscode/.ssh/id_rsa && chmod 600 /home/vscode/.ssh/id_rsa + +# Create a MySQL user to use +echo "[Codespaces] Create MySQL user" +sudo mysql -u root< Date: Sat, 17 Dec 2022 03:11:55 +0000 Subject: [PATCH 2/6] [ticket/17086] Add Codespaces documentation PHPBB3-17086 --- .vscode/launch.json | 2 +- README.md | 5 +++- phpBB/docs/codespaces.md | 55 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 phpBB/docs/codespaces.md diff --git a/.vscode/launch.json b/.vscode/launch.json index b7b7f9be7d..1de76f0106 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Listen for Xdebug", + "name": "Debug phpBB", "type": "php", "request": "launch", "port": 9003, diff --git a/README.md b/README.md index 8c493fd424..af3fb91de7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,10 @@ To run an installation from the repo (and not from a pre-built package) on a loc php ../composer.phar install ``` -Alternatively, you can read our [Vagrant documentation](phpBB/docs/vagrant.md) to find out how to use Vagrant to develop and contribute to phpBB. +Alternatively, you can read: + +* Our [Vagrant documentation](phpBB/docs/vagrant.md) to find out how to use Vagrant to develop and contribute to phpBB. +* Our [GitHub Codespaces documentation](phpBB/docs/codespaces.md) to learn about phpBB's cloud-based development environment. ## 📓 Documentation diff --git a/phpBB/docs/codespaces.md b/phpBB/docs/codespaces.md new file mode 100644 index 0000000000..cc5231f78d --- /dev/null +++ b/phpBB/docs/codespaces.md @@ -0,0 +1,55 @@ +## Using GitHub Codespaces with phpBB + +phpBB includes support for [Codespaces](https://docs.github.com/en/codespaces), GitHub's cloud-based software development environment. This allows developers and contributors to run and modify phpBB on a consistent environment through a GitHub account without the need to set up a local web server. + +Codespaces is completely web-based and does not require any code to be downloaded locally. + +Features include: + +* Automatic phpBB installation +* Access to [VS Code](https://docs.github.com/en/codespaces/the-githubdev-web-based-editor) through the web browser +* [Xdebug](https://github.com/xdebug/vscode-php-debug) pre-configured to step through the phpBB code and add breakpoints +* Full LAMP stack with database access +* Commit, push and test code entirely online + +## How it works + +### To run phpBB in Codespaces + +* On the GitHub.com website, fork the `phpbb/phpbb` repository. +* Under the `Code` button, click the `Codespaces` tab and then the `+` button to create a new Codespace. +* It may take several minutes to configure and install phpBB on the newly created virtual machine. Once it is ready, a web-based VS Code instance will appear. +* Under the `Ports` tab, click on the local address under port 80 to open the private website for the new phpBB installation. + * By default, the login details for the new phpBB installation are `admin` / `mypassword` + * Port 9003 is also open to allow Xdebug connections. + +### To use the command line + +* Click on the `Terminal` tab at the bottom of VS Code and make sure the `bash` window is selected in the right sidebar. +* The `workspaces/phpbb` directory contains the code from the workspace. +* Run `mysql -h 127.0.0.1 -u phpbb -p` to log into the MySQL database. The password is `phpbb` and the database name is `phpbb`. + * Tip: type `use phpbb;` after logging in to MySQL to switch to the correct database, then queries can be run for the phpBB tables. + +### To debug code + +* Click the `Run and Debug` tab on the left sidebar in VS Code, then click the green play button next to the `Debug phpBB` option. + * Tip: to confirm that Xdebug is working correctly, run `lsof -i :9003` on the command line. It should show that the port is listening for connections. +* In any of the files in the `phpBB/` directory, add a breakpoint by clicking just to the left of a line number in VS Code. Then, access the private website created on port 80 (found under the VS Code `Ports` tab) through the web browser and navigate to the page with a breakpoint. VS Code will automatically pause execution where the breakpoint is hit, and under the `Run and Debug` tab a variable list will be shown. + +### To commit and push code + +* To save a change made using VS Code on Codespaces, click the `Source Control` tab on the left sidebar in VS Code. +* To stage changes or discard changes, right click the file(s) and select the appropriate option. +* Type a commit message and select the `Commit and Push` option. + +**Remember to stop a Codespace once you are finished with it.** GitHub provides all users with a limited number of free core hours per month. A Codespace can be stopped (or deleted) from the main repository page on GitHub.com. + +## Technical information + +All of the Codespaces configuration can be found in the `.devcontainer/` directory. The `devcontainer.json` holds the general environment information and `Dockerfile` contains the commands to set up the LAMP stack which enables phpBB to run. + +`setup.sh` is used to install phpBB from the command line, using pre-determined details from `phpbb-config.yml`. + +Codespaces can run without the configuration inside the `.vscode/` directory, however by including this no manual intervention is required to set the Xdebug IDE code to `VSCode` (inside `settings.json`) and `Debug phpBB` information, such as the path mapping from the Apache webroot to the `phpbb/phpBB` directory (inside `launch.json`). + +This configuration information can be safely modified to change the development environment, followed by `Ctrl+Shift+P` in VS Code and selection of the `Full Rebuild Container` option. \ No newline at end of file From 279f506d6968d5813792381b77165ca6262bdd1f Mon Sep 17 00:00:00 2001 From: battye Date: Tue, 10 Jan 2023 02:31:22 +0000 Subject: [PATCH 3/6] [ticket/17086] Codespaces - change admin login PHPBB3-17086 --- .devcontainer/resources/phpbb-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/resources/phpbb-config.yml b/.devcontainer/resources/phpbb-config.yml index 414aef02a2..dd0cf9dbbc 100644 --- a/.devcontainer/resources/phpbb-config.yml +++ b/.devcontainer/resources/phpbb-config.yml @@ -1,7 +1,7 @@ installer: admin: name: admin - password: mypassword + password: adminadmin email: admin@example.org board: From 2c8e16cf4b82f33389f2fb8fed4d1e2dcc31b068 Mon Sep 17 00:00:00 2001 From: battye Date: Tue, 10 Jan 2023 02:46:51 +0000 Subject: [PATCH 4/6] [ticket/17086] Update codespaces.md PHPBB3-17086 --- phpBB/docs/codespaces.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/docs/codespaces.md b/phpBB/docs/codespaces.md index cc5231f78d..c7b5a28af3 100644 --- a/phpBB/docs/codespaces.md +++ b/phpBB/docs/codespaces.md @@ -20,7 +20,7 @@ Features include: * Under the `Code` button, click the `Codespaces` tab and then the `+` button to create a new Codespace. * It may take several minutes to configure and install phpBB on the newly created virtual machine. Once it is ready, a web-based VS Code instance will appear. * Under the `Ports` tab, click on the local address under port 80 to open the private website for the new phpBB installation. - * By default, the login details for the new phpBB installation are `admin` / `mypassword` + * By default, the login details for the new phpBB installation are `admin` / `adminadmin` * Port 9003 is also open to allow Xdebug connections. ### To use the command line From b5f10f844f8077c28c220042b7c4ffc922b8729f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 14 Jan 2023 08:40:49 +0100 Subject: [PATCH 5/6] [ticket/17086] Add missing empty lines and remove extra whitespace PHPBB3-17086 --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 2 +- .devcontainer/resources/phpbb-config.yml | 2 +- .devcontainer/resources/setup.sh | 6 +++--- .devcontainer/resources/xdebug.ini | 2 +- .vscode/launch.json | 2 +- .vscode/settings.json | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3d5b94426e..af0063b2ef 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -17,4 +17,4 @@ ADD resources/xdebug.ini /etc/php/8.1/apache2/conf.d/xdebug.ini # Configure Apache RUN echo "Listen 8080" >> /etc/apache2/ports.conf && \ - a2enmod rewrite \ No newline at end of file + a2enmod rewrite \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 33f13337fb..7bb0e9cc3a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -34,4 +34,4 @@ "features": { "github-cli": "latest" } -} \ No newline at end of file +} diff --git a/.devcontainer/resources/phpbb-config.yml b/.devcontainer/resources/phpbb-config.yml index dd0cf9dbbc..9a9db6abff 100644 --- a/.devcontainer/resources/phpbb-config.yml +++ b/.devcontainer/resources/phpbb-config.yml @@ -35,4 +35,4 @@ installer: server_port: 80 script_path: / - extensions: [] \ No newline at end of file + extensions: [] diff --git a/.devcontainer/resources/setup.sh b/.devcontainer/resources/setup.sh index a2df6777f5..b871db11df 100644 --- a/.devcontainer/resources/setup.sh +++ b/.devcontainer/resources/setup.sh @@ -16,7 +16,7 @@ echo "$SSH_KEY" > /home/vscode/.ssh/id_rsa && chmod 600 /home/vscode/.ssh/id_rsa # Create a MySQL user to use echo "[Codespaces] Create MySQL user" sudo mysql -u root< Date: Sat, 14 Jan 2023 17:17:54 +0000 Subject: [PATCH 6/6] [ticket/17086] Remove trailing slash in Dockerfile PHPBB3-17086 --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index af0063b2ef..ceb94dc09d 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -17,4 +17,4 @@ ADD resources/xdebug.ini /etc/php/8.1/apache2/conf.d/xdebug.ini # Configure Apache RUN echo "Listen 8080" >> /etc/apache2/ports.conf && \ - a2enmod rewrite \ + a2enmod rewrite