From 7196f37e86ca6d83ddd4d435d2574da6b4e68133 Mon Sep 17 00:00:00 2001 From: AydarN <9845662+AydarN@users.noreply.github.com> Date: Thu, 19 Oct 2023 10:43:54 +0300 Subject: [PATCH] OPS-268: Change user (#17) --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7e1e14d..2c3c1c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,8 @@ RUN rebar3 compile && \ FROM docker.io/library/erlang:${OTP_VERSION}-slim ARG SERVICE_NAME +ARG USER_UID=1001 +ARG USER_GID=$USER_UID # Set env ENV CHARSET=UTF-8 @@ -44,6 +46,13 @@ ENV WORK_DIR=/opt/${SERVICE_NAME} RUN echo "#!/bin/sh" >> /entrypoint.sh && \ echo "exec /opt/${SERVICE_NAME}/bin/${SERVICE_NAME} foreground" >> /entrypoint.sh && \ chmod +x /entrypoint.sh + +RUN groupadd --gid ${USER_GID} ${SERVICE_NAME} && \ + mkdir /var/log/${SERVICE_NAME} && \ + chown ${USER_UID}:${USER_GID} /var/log/${SERVICE_NAME} && \ + useradd --uid ${USER_UID} --gid ${USER_GID} -M ${SERVICE_NAME} +USER ${SERVICE_NAME} + ENTRYPOINT [] CMD ["/entrypoint.sh"]