From 5897bfdb7b0ba7e0b54a48a83cac8233e6082246 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 13 Dec 2023 23:51:51 +0000 Subject: [PATCH] Basic devcontainer setup Getting xdebug working on osx is a pain, devcontainers are less pain... --- .devcontainer/devcontainer.json | 40 +++++++++++++++++++++++++++++++++ .gitignore | 1 - Dockerfile | 5 +++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..4a0f654d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile +{ + "name": "Shimmie Dockerfile", + "build": { + "context": "..", + "dockerfile": "../Dockerfile", + "target": "devcontainer" + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "apt update && apt install -y composer php8.2-xdebug git", + + "customizations": { + "vscode": { + "extensions": [ + "recca0120.vscode-phpunit", + "ryanluker.vscode-coverage-gutters" + ], + "settings": { + "phpunit.args": [ + "--configuration", "${workspaceFolder}/tests/phpunit.xml"//, + //"--coverage-clover", "data/coverage.clover" + ], + "coverage-gutters.coverageFileNames": [ + "data/coverage.clover" + ] + } + } + } + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "devcontainer" +} diff --git a/.gitignore b/.gitignore index 4f3b64dc..2edf4170 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ thumbs *.phar *.sqlite *.cache -.devcontainer trace.json #Composer diff --git a/Dockerfile b/Dockerfile index 75508f59..7477642c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN apt update && apt upgrade -y && apt install -y \ # Composer has 100MB of dependencies, and we only need that during build and test FROM base AS composer RUN apt update && apt upgrade -y && apt install -y composer php${PHP_VERSION}-xdebug && rm -rf /var/lib/apt/lists/* +ENV XDEBUG_MODE=coverage # "Build" shimmie (composer install - done in its own stage so that we don't # need to include all the composer fluff in the final image) @@ -36,6 +37,10 @@ RUN [ $RUN_TESTS = false ] || (\ echo '=== Coverage ===' && XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text && \ echo '=== Cleaning ===' && rm -rf data) +# Devcontainer target +FROM composer AS devcontainer +RUN apt update && apt upgrade -y && apt install -y git && rm -rf /var/lib/apt/lists/* + # Actually run shimmie FROM base EXPOSE 8000