From 77afe94446e78e688ebde7a5e2b1249fc0a4afcd Mon Sep 17 00:00:00 2001 From: Benjamin Denhartog Date: Tue, 3 Aug 2021 17:56:21 -0600 Subject: [PATCH] Dockerfile: run as user: linuxbrew This commit refactors the Dockerfile in order to resolve build errors caused by attempting to execute `brew` commands as the root user. We need to create the `/home/linuxbrew/.linuxbrew` folder prior to copying the local directory into `/home/linuxbrew/.linuxbrew/Homebrew` (and ensure the appropriate user owns it), as failing to do so will create `/home/linuxbrew/.linuxbrew` with root user and group ownership, causing the subsequent `mkdir` command called in the second `RUN` instruction to fail. closes #11802 --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1819ad0464..33b584d9ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,9 +29,11 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && localedef -i en_US -f UTF-8 en_US.UTF-8 \ && useradd -m -s /bin/bash linuxbrew \ - && echo 'linuxbrew ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers + && echo 'linuxbrew ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers \ + && su - linuxbrew -c 'mkdir ~/.linuxbrew' -COPY . /home/linuxbrew/.linuxbrew/Homebrew +USER linuxbrew +COPY --chown=linuxbrew:linuxbrew . /home/linuxbrew/.linuxbrew/Homebrew ENV PATH=/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH WORKDIR /home/linuxbrew