From fdf82826b773fdb097cb7d9dca5810890cd820ef Mon Sep 17 00:00:00 2001 From: jmleroux Date: Thu, 23 Jan 2025 11:35:16 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8B=20Fix=20Docker=20to=20work=20with?= =?UTF-8?q?=20user=20ID=20<>=201000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Dockerfile | 4 ++++ docker-compose.yml | 1 + 3 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 2a795af..15c6cef 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ vendor bin/phpspec bin/php-cs-fixer composer.lock +.composer diff --git a/Dockerfile b/Dockerfile index 61610d9..2bcc5e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM php:8.1-cli +ARG DEV_UID=1000 + RUN echo 'APT::Install-Recommends "0" ; APT::Install-Suggests "0" ;' > /etc/apt/apt.conf.d/01-no-recommended && \ echo 'path-exclude=/usr/share/man/*' > /etc/dpkg/dpkg.cfg.d/path_exclusions && \ echo 'path-exclude=/usr/share/doc/*' >> /etc/dpkg/dpkg.cfg.d/path_exclusions && \ @@ -12,3 +14,5 @@ RUN echo 'APT::Install-Recommends "0" ; APT::Install-Suggests "0" ;' > /etc/apt/ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +RUN useradd -u ${DEV_UID} appuser || echo "User exists" && usermod --uid ${DEV_UID} -d /opt/app appuser diff --git a/docker-compose.yml b/docker-compose.yml index 09e4bcf..066b9f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,3 +7,4 @@ services: volumes: - ./:/opt/app working_dir: /opt/app + user: appuser