Skip to content

Commit 84d17a6

Browse files
committed
Add devcontainer config
(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.
1 parent 3a6e43b commit 84d17a6

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM debian:stable
2+
ARG DEBIAN_FRONTEND=noninteractive
3+
ARG XDEBUG_MODE=coverage
4+
RUN apt update -y && apt install -y git composer php-cli php-dom php-curl php-xdebug vim
5+
WORKDIR /app
6+
CMD cd /app/generator/doc && ./update.sh && cd /app/generator && composer install && php ./safe.php generate && composer cs-fix

.devcontainer/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
cd $(dirname $0)/../
3+
docker run --rm -v ${PWD}:/app $(docker build -q -f .devcontainer/Dockerfile .)

.devcontainer/devcontainer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Safe PHP",
3+
"build": {
4+
"context": "..",
5+
"dockerfile": "./Dockerfile"
6+
},
7+
8+
"workspaceMount": "source=${localWorkspaceFolder},target=/app,type=bind",
9+
"workspaceFolder": "/app"
10+
}

.devcontainer/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
cd $(dirname $0)/../
3+
docker run --rm -ti -v ${PWD}:/app $(docker build -q . -f .devcontainer/Dockerfile) /bin/bash

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

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

5+
## Install dependencies
6+
7+
### With a devcontainer
8+
9+
If you use VSCode or similar, opening the project folder should prompt you to
10+
re-open the folder inside a docker container with all the relevant tools
11+
pre-installed.
12+
13+
### Manually
14+
15+
- php8.2+ CLI (with dom and curl modules)
16+
- composer
17+
518
## How to install Safe-PHP development environment
619

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

0 commit comments

Comments
 (0)