From ffa187cb366db1d755c888e6bf06f178afe4df4f Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 15 Nov 2025 20:07:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=20qinglong?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/310.Dockerfile | 26 ++++++++++++++++++++++---- docker/Dockerfile | 25 +++++++++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/docker/310.Dockerfile b/docker/310.Dockerfile index baa4978a..d6cd305e 100644 --- a/docker/310.Dockerfile +++ b/docker/310.Dockerfile @@ -26,6 +26,17 @@ ENV QL_DIR=/ql \ SHELL=/bin/bash \ PS1="\u@\h:\w \$ " +ARG QL_UID=5432 +ARG QL_GID=5432 +RUN groupadd -g ${QL_GID} qinglong && \ + useradd -m -u ${QL_UID} -g ${QL_GID} -s /bin/bash qinglong && \ + mkdir -p /home/qinglong/bin /home/qinglong/.ssh && \ + chmod 700 /home/qinglong/.ssh && \ + chown -R ${QL_UID}:${QL_GID} /home/qinglong + +ENV QL_USER=qinglong +ENV QL_HOME=/home/$QL_USER + COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/ @@ -57,16 +68,21 @@ RUN set -x && \ rm -rf /etc/apt/apt.conf.d/docker-clean && \ ulimit -c 0 +RUN mkdir -p ${QL_DIR} && \ + chown -R ${QL_UID}:${QL_GID} ${QL_DIR} + +USER qinglong + ARG SOURCE_COMMIT RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \ cd ${QL_DIR} && \ cp -f .env.example .env && \ chmod 777 ${QL_DIR}/shell/*.sh && \ chmod 777 ${QL_DIR}/docker/*.sh && \ - git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static && \ + git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /tmp/static && \ mkdir -p ${QL_DIR}/static && \ - cp -rf /static/* ${QL_DIR}/static && \ - rm -rf /static + cp -rf /tmp/static/* ${QL_DIR}/static && \ + rm -rf /tmp/static ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \ PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \ @@ -79,7 +95,9 @@ ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOM RUN pip3 install --prefix ${PYTHON_HOME} requests -COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/ +COPY --chown=qinglong:qinglong --from=builder /tmp/build/node_modules/. /ql/node_modules/ + +USER root WORKDIR ${QL_DIR} diff --git a/docker/Dockerfile b/docker/Dockerfile index 507c18f8..1a2eca4a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -26,6 +26,17 @@ ENV QL_DIR=/ql \ SHELL=/bin/bash \ PS1="\u@\h:\w \$ " +ARG QL_UID=5432 +ARG QL_GID=5432 +RUN groupadd -g ${QL_GID} qinglong && \ + useradd -m -u ${QL_UID} -g ${QL_GID} -s /bin/bash qinglong && \ + mkdir -p /home/qinglong/bin /home/qinglong/.ssh && \ + chmod 700 /home/qinglong/.ssh && \ + chown -R ${QL_UID}:${QL_GID} /home/qinglong + +ENV QL_USER=qinglong +ENV QL_HOME=/home/$QL_USER + COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/ @@ -58,16 +69,20 @@ RUN set -x && \ rm -rf /etc/apt/apt.conf.d/docker-clean && \ ulimit -c 0 +RUN mkdir -p ${QL_DIR} && \ + chown -R ${QL_UID}:${QL_GID} ${QL_DIR} + +USER qinglong ARG SOURCE_COMMIT RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \ cd ${QL_DIR} && \ cp -f .env.example .env && \ chmod 777 ${QL_DIR}/shell/*.sh && \ chmod 777 ${QL_DIR}/docker/*.sh && \ - git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static && \ + git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /tmp/static && \ mkdir -p ${QL_DIR}/static && \ - cp -rf /static/* ${QL_DIR}/static && \ - rm -rf /static + cp -rf /tmp/static/* ${QL_DIR}/static && \ + rm -rf /tmp/static ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \ PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \ @@ -80,7 +95,9 @@ ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOM RUN pip3 install --prefix ${PYTHON_HOME} requests -COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/ +COPY --chown=qinglong:qinglong --from=builder /tmp/build/node_modules/. /ql/node_modules/ + +USER root WORKDIR ${QL_DIR}