From eb851f6a79ea3e4523de9680e9764b6f3caba2c0 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 7 Sep 2022 12:02:07 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9B=E3=82=B9=E3=83=88=E3=81=AE=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=AE=20UID=20=E3=81=A8=20GID=20?= =?UTF-8?q?=E3=82=92=20www-data=20=E3=81=AB=E3=83=9E=E3=83=83=E3=83=94?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 以下のように docker-compose コマンドを実行することで、ホストのユーザー の UID 及び GID を www-data ユーザーにマッピングできる ``` UID=${UID} GID=${GID} docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d ``` --- docker-compose.dev.yml | 3 +++ dockerbuild/docker-php-entrypoint | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index eee9a9585f7..6a3a8499be1 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -2,5 +2,8 @@ version: '3' services: ec-cube: + environment: + USER_ID: ${UID:-} + GROUP_ID: ${GID:-} volumes: - ".:/var/www/html:cached" diff --git a/dockerbuild/docker-php-entrypoint b/dockerbuild/docker-php-entrypoint index e77990554b3..4441ddda78b 100755 --- a/dockerbuild/docker-php-entrypoint +++ b/dockerbuild/docker-php-entrypoint @@ -1,6 +1,13 @@ #!/bin/sh set -e +if [ -n "${USER_ID}" ]; then + usermod -u ${USER_ID} -o www-data +fi +if [ -n "${GROUP_ID}" ]; then + groupmod -g ${GROUP_ID} www-data +fi + if [ ! -d /var/www/html/vendor/bin ]; then composer install \ --no-scripts \