From bef3f35720b2a2a6dd352dc201392f831286894b Mon Sep 17 00:00:00 2001 From: Marijn <25235249+2zqa@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:05:37 +0000 Subject: [PATCH 1/4] Add dev container --- .devcontainer/Dockerfile | 18 ++++++++++++++ .devcontainer/devcontainer.json | 18 ++++++++++++++ .devcontainer/docker-compose.yml | 42 ++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..93a5aa7 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,18 @@ +FROM mcr.microsoft.com/devcontainers/php:1-8.2-bookworm + +# Install MariaDB client and other dependencies +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y mariadb-client libpng-dev libsodium-dev libwebp-dev libfreetype6-dev \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* + +# Install the PHP extensions we need +RUN docker-php-ext-configure gd \ + --with-webp \ + --with-freetype \ + && docker-php-ext-install gd mysqli pdo pdo_mysql sodium pcntl + +# Enable redis extension +RUN pecl install redis && docker-php-ext-enable redis + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..cec87d6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,18 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb +{ + "name": "Hypixel Signatures", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "forwardPorts": [ + 8000, // artisan serve + 3306 // MySQL + ], + "features": { + "ghcr.io/devcontainers/features/node:1": { + "pnpmVersion": "latest" + } + }, + "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..d66f5f6 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,42 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + + volumes: + - ../..:/workspaces:cached + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + db: + image: mariadb:10.4 + restart: unless-stopped + volumes: + - mariadb-data:/var/lib/mysql + network_mode: service:app + environment: + MYSQL_ROOT_PASSWORD: mariadb + MYSQL_DATABASE: homestead + MYSQL_USER: homestead + MYSQL_PASSWORD: secret + # Add "forwardPorts": ["3306"] to **devcontainer.json** to forward MariaDB locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + redis: + image: redis:6 + restart: unless-stopped + network_mode: service:app + + # Add "forwardPorts": ["6379"] to **devcontainer.json** to forward Redis locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + +volumes: + mariadb-data: From 57270d15380f56fc4c151d9951fefe3a74fc678e Mon Sep 17 00:00:00 2001 From: 2zqa <25235249+2zqa@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:30:26 +0000 Subject: [PATCH 2/4] Remove postCreateCommand --- .devcontainer/devcontainer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cec87d6..573926f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,6 +13,5 @@ "ghcr.io/devcontainers/features/node:1": { "pnpmVersion": "latest" } - }, - "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html" + } } From 640938ec22c0678b9f222d19f8567265d76c07d8 Mon Sep 17 00:00:00 2001 From: 2zqa <25235249+2zqa@users.noreply.github.com> Date: Tue, 22 Oct 2024 02:08:11 +0200 Subject: [PATCH 3/4] Add editorconfig support --- .devcontainer/Dockerfile | 10 +++++----- .devcontainer/devcontainer.json | 33 ++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 93a5aa7..6c5d624 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,14 +2,14 @@ FROM mcr.microsoft.com/devcontainers/php:1-8.2-bookworm # Install MariaDB client and other dependencies RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get install -y mariadb-client libpng-dev libsodium-dev libwebp-dev libfreetype6-dev \ - && apt-get clean -y && rm -rf /var/lib/apt/lists/* + && apt-get install -y mariadb-client libpng-dev libsodium-dev libwebp-dev libfreetype6-dev \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* # Install the PHP extensions we need RUN docker-php-ext-configure gd \ - --with-webp \ - --with-freetype \ - && docker-php-ext-install gd mysqli pdo pdo_mysql sodium pcntl + --with-webp \ + --with-freetype \ + && docker-php-ext-install gd mysqli pdo pdo_mysql sodium pcntl # Enable redis extension RUN pecl install redis && docker-php-ext-enable redis diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 573926f..3f0dabe 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,17 +1,24 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb { - "name": "Hypixel Signatures", - "dockerComposeFile": "docker-compose.yml", - "service": "app", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - "forwardPorts": [ - 8000, // artisan serve - 3306 // MySQL - ], - "features": { - "ghcr.io/devcontainers/features/node:1": { - "pnpmVersion": "latest" - } - } + "name": "Hypixel Signatures", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "forwardPorts": [ + 8000, // artisan serve + 3306 // MySQL + ], + "features": { + "ghcr.io/devcontainers/features/node:1": { + "pnpmVersion": "latest" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "EditorConfig.EditorConfig" + ] + } + } } From e1106bc8689b7bdde63739977a1c4b297a1e8089 Mon Sep 17 00:00:00 2001 From: 2zqa <25235249+2zqa@users.noreply.github.com> Date: Tue, 22 Oct 2024 00:50:09 +0000 Subject: [PATCH 4/4] Add xdebug config --- .devcontainer/Dockerfile | 6 ++++-- .devcontainer/devcontainer.json | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6c5d624..32dd270 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -14,5 +14,7 @@ RUN docker-php-ext-configure gd \ # Enable redis extension RUN pecl install redis && docker-php-ext-enable redis -# [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 +# Configure Xdebug +RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini \ + # && echo "xdebug.start_with_request=trigger" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/xdebug.ini diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3f0dabe..462defc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,8 @@ "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "forwardPorts": [ 8000, // artisan serve - 3306 // MySQL + 3306, // MySQL + 9003 // Xdebug ], "features": { "ghcr.io/devcontainers/features/node:1": {