Skip to content

Commit

Permalink
Merge pull request #238 from Automattic/add-entrypoints-feature
Browse files Browse the repository at this point in the history
feat: add `entrypoints` feature
  • Loading branch information
sjinks authored Jun 17, 2024
2 parents d36fafd + 8e23925 commit ea6e4f7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- cron
- dev-tools
- elasticsearch
- entrypoints
- php
- mailpit
- mariadb
Expand Down
7 changes: 7 additions & 0 deletions features/src/entrypoints/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "entrypoints",
"name": "Entrypoint Runner",
"description": "Runs entrypoint scripts for images without runit",
"version": "1.0.0",
"entrypoint": "/usr/local/bin/entrypoint-runner"
}
9 changes: 9 additions & 0 deletions features/src/entrypoints/entrypoint-runner
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin

if [ -x /usr/local/bin/runit-wrapper ] || [ -x /lib/runit/runit-init ] || [ ! -d /var/lib/entrypoint.d ]; then
exit 0
fi

exec run-parts /var/lib/entrypoint.d
11 changes: 11 additions & 0 deletions features/src/entrypoints/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin

if [ "$(id -u || true)" -ne 0 ]; then
echo 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi

install -D -d -m 0755 -o root -g root /var/lib/entrypoint.d
install -m 0755 -o root -g root entrypoint-runner /usr/local/bin/entrypoint-runner
7 changes: 7 additions & 0 deletions features/test/entrypoints/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# shellcheck source=/dev/null
source dev-container-features-test-lib

check "/var/lib/entrypoint.d exists" test -d /var/lib/entrypoint.d
check "/usr/local/bin/entrypoint-runner exists and is executable" test -x /usr/local/bin/entrypoint-runner

0 comments on commit ea6e4f7

Please sign in to comment.