Skip to content

Commit

Permalink
Add devcontainer config
Browse files Browse the repository at this point in the history
(breaking shish/safe down into smaller parts for easier merging)

These configs make it so that one can open the Safe project in a compatible editor (eg vscode) and the IDE will do all the work (eg build, test) in a self-contained container with all the right versions of all the right tools installed. This is particularly useful for Safe, whose build process only runs with specific PHP versions, which may differ from what is installed on the developer's host system.
  • Loading branch information
shish authored and staabm committed Nov 28, 2024
1 parent cf6662e commit 873fdc4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM debian:stable
ARG DEBIAN_FRONTEND=noninteractive
ARG XDEBUG_MODE=coverage
RUN apt update -y && apt install -y git composer php-cli php-dom php-curl php-xdebug vim
WORKDIR /app
CMD cd /app/generator/doc && ./update.sh && cd /app/generator && composer install && php ./safe.php generate && composer cs-fix
3 changes: 3 additions & 0 deletions .devcontainer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
cd $(dirname $0)/../
docker run --rm -v ${PWD}:/app $(docker build -q -f .devcontainer/Dockerfile .)
10 changes: 10 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "Safe PHP",
"build": {
"context": "..",
"dockerfile": "./Dockerfile"
},

"workspaceMount": "source=${localWorkspaceFolder},target=/app,type=bind",
"workspaceFolder": "/app"
}
3 changes: 3 additions & 0 deletions .devcontainer/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
cd $(dirname $0)/../
docker run --rm -ti -v ${PWD}:/app $(docker build -q . -f .devcontainer/Dockerfile) /bin/bash
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

Safe-PHP code is generated automatically from the PHP doc.

## Install dependencies

### With a devcontainer

If you use VSCode or similar, opening the project folder should prompt you to
re-open the folder inside a docker container with all the relevant tools
pre-installed.

### Manually

- php8.2+ CLI (with dom and curl modules)
- composer

## How to install Safe-PHP development environment

The first step is to download the PHP documentation project locally, using git.
Expand Down

0 comments on commit 873fdc4

Please sign in to comment.