Skip to content

Commit

Permalink
Update Docker user and group settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydrogers committed Dec 21, 2023
1 parent a7c7a31 commit c8a56df
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/actions/new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ action_new(){
shift 1
latest_image=$SPIN_PHP_IMAGE
docker pull $latest_image
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 "$@"
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 "$@"
install_spin_package_to_project php "${@:-laravel}" --force
source "$SPIN_HOME/lib/actions/init.sh"
action_init --template=laravel --project-directory="${@:-laravel}" --force
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ action_php(){
$COMPOSE_CMD run --remove-orphans --no-deps --rm \
--entrypoint '' \
-e "LOG_LEVEL=off" \
--user $SPIN_DEFAULT_PHP_USER \
--user "$SPIN_DEFAULT_PHP_USER:$SPIN_GROUP_ID" \
$SPIN_DEFAULT_PHP_SERVICE_NAME \
"${args[@]}"
}
8 changes: 5 additions & 3 deletions templates/laravel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ FROM serversideup/php:beta-8.3-fpm-nginx as base
FROM base as development

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

FROM base as deploy
COPY --chown=www-data:www-data . /var/www/html
1 change: 1 addition & 0 deletions templates/laravel/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
target: development
args:
USER_ID: ${SPIN_USER_ID}
GROUP_ID: ${SPIN_GROUP_ID}
volumes:
- .:/var/www/html/
networks:
Expand Down

0 comments on commit c8a56df

Please sign in to comment.