Skip to content

Commit a7c7a31

Browse files
committed
Add PHP action and default users
1 parent c705dab commit a7c7a31

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

bin/spin

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ SPIN_PHP_IMAGE=${SPIN_PHP_IMAGE:-"serversideup/php:beta-cli"}
1515
SPIN_NODE_IMAGE=${SPIN_NODE_IMAGE:-"node:20"}
1616
SPIN_ANSIBLE_IMAGE=${SPIN_ANSIBLE_IMAGE:-"willhallonline/ansible:2.15-alpine-3.18"}
1717

18+
### Default Users
19+
SPIN_DEFAULT_PHP_USER=${SPIN_DEFAULT_RUN_USER_PHP:-"www-data"}
20+
SPIN_DEFAULT_PHP_SERVICE_NAME=${SPIN_DEFAULT_PHP_RUN_SERVICE:-"php"}
21+
1822
# Import common functions
1923
source "$SPIN_HOME/lib/functions.sh"
2024

@@ -118,6 +122,10 @@ main() {
118122
source "$SPIN_HOME/lib/actions/new.sh"
119123
action_new "$@"
120124
;;
125+
php)
126+
source "$SPIN_HOME/lib/actions/php.sh"
127+
action_php "$@"
128+
;;
121129
provision)
122130
source "$SPIN_HOME/lib/actions/provision.sh"
123131
action_provision "$@"

lib/actions/new.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ action_new(){
88
shift 1
99
latest_image=$SPIN_PHP_IMAGE
1010
docker pull $latest_image
11-
docker run --rm -w /var/www/html -v $(pwd):/var/www/html -e "LOG_LEVEL=off" $latest_image composer create-project laravel/laravel "$@"
11+
docker run --rm -w /var/www/html -v $(pwd):/var/www/html --user ${SPIN_USER_ID} -e "LOG_LEVEL=off" $latest_image composer create-project laravel/laravel "$@"
1212
install_spin_package_to_project php "${@:-laravel}" --force
1313
source "$SPIN_HOME/lib/actions/init.sh"
1414
action_init --template=laravel --project-directory="${@:-laravel}" --force

lib/actions/php.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
action_php(){
3+
docker_pull_check "$@"
4+
5+
local args=($(filter_out_spin_arguments "$@"))
6+
7+
# Run Docker Compose without dependencies. Ensure automations and S6 logging are disabled
8+
$COMPOSE_CMD run --remove-orphans --no-deps --rm \
9+
--entrypoint '' \
10+
-e "LOG_LEVEL=off" \
11+
--user $SPIN_DEFAULT_PHP_USER \
12+
$SPIN_DEFAULT_PHP_SERVICE_NAME \
13+
"${args[@]}"
14+
}

0 commit comments

Comments
 (0)