Build/Test Tools: Improve devcontainer setup for non-Codespaces usage

This now runs in local Docker as well. Sets the executable propset to explicitly identify `install-tool.sh` and `setup.sh` as executable. Unclear if this will sync via the Git mirror; ideally it would as otherwise the two files show as modified in a Git clone even in a fresh container.

Props samruddhikhandale.
See #57187.


git-svn-id: https://develop.svn.wordpress.org/trunk@55353 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Helen Hou-Sandi 2023-02-16 03:48:26 +00:00
parent 8d3009deef
commit 5a87725ed9
4 changed files with 9 additions and 6 deletions

View File

@ -2,7 +2,7 @@
{
"name": "WordPress Core Development",
"dockerComposeFile": "docker-compose.yml",
"service": "wordpress",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.

View File

@ -1,7 +1,7 @@
version: '3.1'
services:
wordpress:
app:
image: wordpress
restart: always
ports:
@ -12,11 +12,11 @@ services:
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- ../src:/var/www/html
- ../..:/workspaces:cached
db:
image: mariadb
restart: always
restart: unless-stopped
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
@ -26,5 +26,4 @@ services:
- db:/var/lib/mysql
volumes:
wordpress:
db:

4
.devcontainer/install-tools.sh Normal file → Executable file
View File

@ -7,5 +7,9 @@ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.pha
sudo chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
echo "Installing chromium..."
sudo apt-get update
sudo apt-get -y install --no-install-recommends chromium
# Copy the welcome message
sudo cp .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt

2
.devcontainer/setup.sh Normal file → Executable file
View File

@ -2,7 +2,7 @@
set -eux
if [ "${CODESPACE_NAME}" = "" ]; then
if [ -z ${CODESPACE_NAME+x} ]; then
SITE_HOST="http://localhost:8080"
else
SITE_HOST="https://${CODESPACE_NAME}-8080.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"