Skip to content

Commit

Permalink
Basic devcontainer setup
Browse files Browse the repository at this point in the history
Getting xdebug working on osx is a pain, devcontainers are less pain...
  • Loading branch information
shish committed Dec 14, 2023
1 parent fd1bb21 commit 5897bfd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ thumbs
*.phar
*.sqlite
*.cache
.devcontainer
trace.json

#Composer
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 5897bfd

Please sign in to comment.