From 5a17dd6f4ac45058658e2aeb1f1e852190f3dfaf Mon Sep 17 00:00:00 2001
From: lijianguo <lijianguo@zhumengyuan.com>
Date: Mon, 7 Mar 2022 14:12:58 +0800
Subject: [PATCH] chore(dockerfile): use uid gid

---
 rootfs/Dockerfile      | 25 ++++++++++++-------------
 rootfs/Dockerfile.test | 26 +++++++++++++-------------
 2 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/rootfs/Dockerfile b/rootfs/Dockerfile
index dd1c8ad..b7b6ea4 100644
--- a/rootfs/Dockerfile
+++ b/rootfs/Dockerfile
@@ -1,31 +1,30 @@
 FROM docker.io/drycc/base:bullseye
 
-ARG DRYCC_UID=1001
-ARG DRYCC_GID=1001
-ARG DRYCC_HOME_DIR=/workspace
+ENV DRYCC_UID=1001 \
+  DRYCC_GID=1001 \
+  DRYCC_HOME_DIR=/workspace \
+  PYTHON_VERSION="3.10.2" \
+  HELM_VERSION="3.8.0"
 
 RUN groupadd drycc --gid ${DRYCC_GID} \
   && useradd drycc -u ${DRYCC_UID} -g ${DRYCC_GID} -s /bin/bash -m -d ${DRYCC_HOME_DIR}
 
-ENV PYTHON_VERSION="3.10.2" \
-  HELM_VERSION="3.8.0"
-
 COPY . ${DRYCC_HOME_DIR}
-
 WORKDIR ${DRYCC_HOME_DIR}
+
 RUN buildDeps='musl-dev openssl' \
-  && install-packages $buildDeps \
-  && install-stack python $PYTHON_VERSION \
-  && install-stack helm $HELM_VERSION && . init-stack \
+  && install-packages ${buildDeps} \
+  && install-stack python ${PYTHON_VERSION} \
+  && install-stack helm ${HELM_VERSION} && . init-stack \
   && python3 -m venv ${DRYCC_HOME_DIR}/.venv \
   && source ${DRYCC_HOME_DIR}/.venv/bin/activate \
   && pip3 install --disable-pip-version-check --no-cache-dir -r ${DRYCC_HOME_DIR}/requirements.txt \
-  && chown -R drycc:drycc ${DRYCC_HOME_DIR} \
+  && chown -R ${DRYCC_UID}:${DRYCC_GID} ${DRYCC_HOME_DIR} \
   # set env
   && echo "source ${DRYCC_HOME_DIR}/.venv/bin/activate" >> /opt/drycc/python/profile.d/python.sh \
   # cleanup
   && scanelp ${DRYCC_HOME_DIR}/.venv/lib > runtime.txt \
-  && apt-get purge -y --auto-remove $buildDeps \
+  && apt-get purge -y --auto-remove ${buildDeps} \
   && install-packages $(< runtime.txt) \
   && apt-get autoremove -y \
   && apt-get clean -y \
@@ -44,7 +43,7 @@ RUN buildDeps='musl-dev openssl' \
         /usr/lib/`echo $(uname -m)`-linux-gnu/gconv/EBC* \
   && mkdir -p /usr/share/man/man{1..8}
 
-USER drycc
+USER ${DRYCC_UID}
 WORKDIR ${DRYCC_HOME_DIR}
 CMD ["bin/boot"]
 EXPOSE 8000
diff --git a/rootfs/Dockerfile.test b/rootfs/Dockerfile.test
index 802e034..60a592b 100644
--- a/rootfs/Dockerfile.test
+++ b/rootfs/Dockerfile.test
@@ -1,33 +1,33 @@
 FROM docker.io/drycc/base:bullseye
 
-ARG DRYCC_UID=1001
-ARG DRYCC_GID=1001
-ARG DRYCC_HOME_DIR=/workspace
+ENV DRYCC_UID=1001 \
+  DRYCC_GID=1001 \
+  DRYCC_HOME_DIR=/workspace \
+  PYTHON_VERSION="3.10.2" \
+  HELM_VERSION="3.8.0" \
+  KUBECTL_VERSION="1.23.4"
 
 RUN groupadd drycc --gid ${DRYCC_GID} \
   && useradd drycc -u ${DRYCC_UID} -g ${DRYCC_GID} -s /bin/bash -m -d ${DRYCC_HOME_DIR}
-ENV PYTHON_VERSION="3.10.2" \
-  HELM_VERSION="3.8.0" \
-  KUBECTL_VERSION="1.23.4"
 
 COPY . ${DRYCC_HOME_DIR}
 WORKDIR ${DRYCC_HOME_DIR}
 
 RUN buildDeps='musl-dev openssl'; \
-  install-packages $buildDeps \
-  && install-stack python $PYTHON_VERSION \
-  && install-stack helm $HELM_VERSION \
-  && install-stack kubectl $KUBECTL_VERSION && . init-stack \
+  install-packages ${buildDeps} \
+  && install-stack python ${PYTHON_VERSION} \
+  && install-stack helm ${HELM_VERSION} \
+  && install-stack kubectl ${KUBECTL_VERSION} && . init-stack \
   && python3 -m venv ${DRYCC_HOME_DIR}/.venv \
   && source ${DRYCC_HOME_DIR}/.venv/bin/activate \
   && pip3 install --disable-pip-version-check --no-cache-dir -r ${DRYCC_HOME_DIR}/requirements.txt \
   && pip3 install --disable-pip-version-check --no-cache-dir -r ${DRYCC_HOME_DIR}/dev_requirements.txt \
-  && chown -R drycc:drycc ${DRYCC_HOME_DIR} \
+  && chown -R ${DRYCC_UID}:${DRYCC_GID} ${DRYCC_HOME_DIR} \
   # set env
   && echo "source ${DRYCC_HOME_DIR}/.venv/bin/activate" >> /opt/drycc/python/profile.d/python.sh \
   # cleanup
   && scanelp ${DRYCC_HOME_DIR}/.venv/lib > runtime.txt \
-  && apt-get purge -y --auto-remove $buildDeps \
+  && apt-get purge -y --auto-remove ${buildDeps} \
   && install-packages $(< runtime.txt) \
   && apt-get autoremove -y \
   && apt-get clean -y \
@@ -46,7 +46,7 @@ RUN buildDeps='musl-dev openssl'; \
         /usr/lib/`echo $(uname -m)`-linux-gnu/gconv/EBC* \
   && mkdir -p /usr/share/man/man{1..8}
 
-USER drycc
+USER ${DRYCC_UID}
 WORKDIR ${DRYCC_HOME_DIR}
 CMD ["bin/boot"]
 EXPOSE 8000
