Skip to content

Commit a645095

Browse files
garrettwjordikroon
andauthored
Create Devcontainer config (#4793)
* created basic devcontainer config --------- Co-authored-by: Jordi Kroon <jordikroon@php.net>
1 parent 3d4ee5f commit a645095

4 files changed

Lines changed: 123 additions & 0 deletions

File tree

.devcontainer/build.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
FORMAT="${1:-xhtml}"
6+
7+
case "$FORMAT" in
8+
xhtml) OUTDIR="output/php-chunked-xhtml" ;;
9+
php) OUTDIR="output/php-web" ;;
10+
*) echo "Usage: $0 [xhtml|php]" >&2; exit 1 ;;
11+
esac
12+
13+
# doc-base invokes `java -jar jing.jar` with no flags, so the only handle on
14+
# the JAXP entity-size limit is the JVM env vars. The PHP manual is well past
15+
# the 100k default and we have no other way to lift the limit.
16+
export _JAVA_OPTIONS='-Djdk.xml.totalEntitySizeLimit=0 -Djdk.xml.entityExpansionLimit=0 -Djdk.xml.maxGeneralEntitySizeLimit=0'
17+
18+
php ../doc-base/configure.php \
19+
--disable-libxml-check \
20+
--enable-xml-details \
21+
--redirect-stderr-to-stdout \
22+
--with-lang=en
23+
24+
php -d memory_limit=512M ../phd/render.php \
25+
--docbook ../doc-base/.manual.xml \
26+
--output ./output \
27+
--package PHP \
28+
--format "$FORMAT"
29+
30+
pkill -f 'php -S 0.0.0.0:8080' 2>/dev/null || true
31+
exec php -S 0.0.0.0:8080 -t "$OUTDIR"

.devcontainer/devcontainer.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/php
3+
{
4+
"name": "PHP",
5+
"image": "mcr.microsoft.com/devcontainers/php:8.4-trixie",
6+
7+
// Features to add to the dev container. More info: https://containers.dev/features.
8+
"features": {
9+
"ghcr.io/devcontainers/features/github-cli:1": {},
10+
"ghcr.io/devcontainers/features/java:1": {
11+
"version": "lts",
12+
"installGradle": false,
13+
"installMaven": false
14+
}
15+
},
16+
17+
// Configure tool-specific properties.
18+
"customizations": {
19+
// Configure properties specific to VS Code.
20+
"vscode": {
21+
"extensions": [
22+
"editorconfig.editorconfig",
23+
"redhat.vscode-xml"
24+
],
25+
// Workspace-level launch config
26+
"settings": {
27+
"launch": {
28+
"version": "0.2.0",
29+
"configurations": [
30+
{
31+
"name": "Build XHTML & serve",
32+
"type": "node-terminal",
33+
"request": "launch",
34+
"command": ".devcontainer/build.sh xhtml"
35+
},
36+
{
37+
"name": "Build PHP web & serve",
38+
"type": "node-terminal",
39+
"request": "launch",
40+
"command": ".devcontainer/build.sh php"
41+
}
42+
]
43+
}
44+
}
45+
}
46+
},
47+
48+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
49+
"forwardPorts": [
50+
8080
51+
],
52+
53+
// Use 'postCreateCommand' to run commands after the container is created.
54+
"postCreateCommand": "sudo .devcontainer/post-create.sh",
55+
56+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
57+
// "remoteUser": "root"
58+
}

.devcontainer/post-create.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
WORKSPACE="$(cd "$(dirname "$0")/.." && pwd)"
6+
PARENT="$(dirname "$WORKSPACE")"
7+
OWNER="$(stat -c '%U' "$WORKSPACE")"
8+
9+
# Clone doc-base and phd as siblings of doc-en
10+
[ -d "$PARENT/doc-base" ] || sudo -u "$OWNER" git -C "$PARENT" clone --depth 1 https://github.com/php/doc-base.git
11+
[ -d "$PARENT/phd" ] || sudo -u "$OWNER" git -C "$PARENT" clone --depth 1 https://github.com/php/phd.git
12+
13+
# doc-base's configure.php looks for the language source as a sibling directory
14+
[ -e "$PARENT/en" ] || sudo -u "$OWNER" ln -s "$WORKSPACE" "$PARENT/en"
15+
16+
# Xdebug degrades performance and is not needed for the build, so disable it by default.
17+
rm -f /usr/local/etc/php/conf.d/xdebug.ini
18+
19+
# Pre-create the served directory
20+
sudo -u "$OWNER" mkdir -p "$WORKSPACE/output/php-chunked-xhtml"
21+
22+
cat <<'EOF'
23+
24+
Devcontainer ready.
25+
26+
Build & serve: F5 > "Build XHTML & serve" (or "Build PHP web & serve")
27+
28+
View them: http://localhost:8080
29+
30+
EOF

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
version: 2
22
updates:
3+
- package-ecosystem: "devcontainers"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
37
- package-ecosystem: "github-actions"
48
directory: "/"
59
schedule:

0 commit comments

Comments
 (0)