From c110d892da885e9215dad0fc9be494aed1fc4a70 Mon Sep 17 00:00:00 2001 From: rafzei <13080132+rafzei@users.noreply.github.com> Date: Thu, 25 Jun 2020 11:20:26 +0200 Subject: [PATCH] Docker image user permissions fix (#1373) (#1378) * Docker image user permissions fix (#1373) + got rid of empty continuation line warning * Add reference to env var provided in Dockerfile * Add build dir for backward compatibility --- core/src/epicli/Dockerfile | 18 +++++++++--------- core/src/epicli/cli/helpers/Config.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/src/epicli/Dockerfile b/core/src/epicli/Dockerfile index c0b8e3a364..2fd68a481d 100644 --- a/core/src/epicli/Dockerfile +++ b/core/src/epicli/Dockerfile @@ -1,12 +1,11 @@ FROM python:3.7-slim ARG EPICLI_VERSION - ARG USERNAME=epiuser ARG USER_UID=1000 ARG USER_GID=$USER_UID -ENV DOCKER_CLI Yes +ENV EPICLI_DOCKER_SHARED_DIR=/shared COPY /dist/ /epicli WORKDIR /epicli @@ -14,23 +13,24 @@ WORKDIR /epicli RUN apt-get update \ && apt-get -y install gcc make musl-dev libffi-dev tar unzip openssh-client vim \ && apt-get -y install ruby-full \ - && gem install serverspec rake rspec_junit_formatter + && gem install serverspec rake rspec_junit_formatter RUN pip install epicli-${EPICLI_VERSION}-py3-none-any.whl RUN groupadd --gid $USER_GID $USERNAME \ && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ && apt-get install -y sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - + && chmod 0440 /etc/sudoers.d/$USERNAME \ && apt-get autoremove -y \ && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* + +RUN mkdir $EPICLI_DOCKER_SHARED_DIR \ + ;chown :$USERNAME $EPICLI_DOCKER_SHARED_DIR \ + && chmod g+w $EPICLI_DOCKER_SHARED_DIR -RUN mkdir /shared/ -WORKDIR /shared +WORKDIR $EPICLI_DOCKER_SHARED_DIR USER $USERNAME diff --git a/core/src/epicli/cli/helpers/Config.py b/core/src/epicli/cli/helpers/Config.py index 11a4e59bac..af5d14bc1f 100644 --- a/core/src/epicli/cli/helpers/Config.py +++ b/core/src/epicli/cli/helpers/Config.py @@ -4,11 +4,11 @@ class Config: class __ConfigBase: def __init__(self): - self._docker_cli = bool(os.environ.get('DOCKER_CLI', '')) + self._docker_cli = bool(os.environ.get('EPICLI_DOCKER_SHARED_DIR','')) self._output_dir = None if self._docker_cli: - self._output_dir = '/shared/build/' + self._output_dir = os.path.join(os.environ.get('EPICLI_DOCKER_SHARED_DIR'), 'build') self._log_file = 'log.log' self._log_format = '%(asctime)s %(levelname)s %(name)s - %(message)s'