Skip to content

Commit c8a56df

Browse files
committed
Update Docker user and group settings
1 parent a7c7a31 commit c8a56df

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

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 --user ${SPIN_USER_ID} -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_DEFAULT_PHP_USER:$SPIN_GROUP_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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ action_php(){
88
$COMPOSE_CMD run --remove-orphans --no-deps --rm \
99
--entrypoint '' \
1010
-e "LOG_LEVEL=off" \
11-
--user $SPIN_DEFAULT_PHP_USER \
11+
--user "$SPIN_DEFAULT_PHP_USER:$SPIN_GROUP_ID" \
1212
$SPIN_DEFAULT_PHP_SERVICE_NAME \
1313
"${args[@]}"
1414
}

templates/laravel/Dockerfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ FROM serversideup/php:beta-8.3-fpm-nginx as base
66
FROM base as development
77

88
# Fix permission issues in development
9-
# by setting the "www-data" user to the same UID as
10-
# the developer's user.
9+
# by setting the "www-data" user to the
10+
# same user and group that is running docker.
1111
ARG USER_ID
12-
RUN usermod -u $USER_ID www-data
12+
ARG GROUP_ID
13+
RUN usermod -u $USER_ID www-data && \
14+
groupmod -g $GROUP_ID www-data
1315

1416
FROM base as deploy
1517
COPY --chown=www-data:www-data . /var/www/html

templates/laravel/docker-compose.dev.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020
target: development
2121
args:
2222
USER_ID: ${SPIN_USER_ID}
23+
GROUP_ID: ${SPIN_GROUP_ID}
2324
volumes:
2425
- .:/var/www/html/
2526
networks:

0 commit comments

Comments
 (0)