mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-13 06:16:12 +08:00
- Guard /etc/resolv.conf write and crond behind root check in entrypoint;
non-root containers now stay alive via 'tail -f /dev/null' instead of
failing when crond exits with EPERM
- Set PM2_HOME to ${QL_DIR}/data/.pm2 (inside the data volume) so PM2
does not fall back to /root/.pm2, which is inaccessible to non-root users
- Pre-create /ql/.tmp and /ql/shell/preload during image build and make
them world-writable so non-root processes can write runtime files
- Wrap directory creation in initFile.ts with try/catch + recursive:true
so a permission error on ~/.ssh (HOME=/root for non-root user) is logged
as a warning instead of crashing the server init
93 lines
2.7 KiB
Docker
93 lines
2.7 KiB
Docker
FROM python:3.11-alpine3.18 AS builder
|
|
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
|
RUN set -x \
|
|
&& apk update \
|
|
&& apk add nodejs npm git \
|
|
&& npm i -g pnpm@8.3.1 pm2 ts-node \
|
|
&& cd /tmp/build \
|
|
&& pnpm install --prod
|
|
|
|
FROM python:3.11-alpine
|
|
|
|
ARG QL_MAINTAINER="whyour"
|
|
LABEL maintainer="${QL_MAINTAINER}"
|
|
ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
|
|
ARG QL_BRANCH=develop
|
|
ARG PYTHON_SHORT_VERSION=3.11
|
|
|
|
ENV QL_DIR=/ql \
|
|
QL_BRANCH=${QL_BRANCH} \
|
|
LANG=C.UTF-8 \
|
|
SHELL=/bin/bash \
|
|
PS1="\u@\h:\w \$ "
|
|
|
|
VOLUME /ql/data
|
|
|
|
EXPOSE 5700
|
|
|
|
COPY --from=builder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
|
COPY --from=builder /usr/local/bin/. /usr/local/bin/
|
|
|
|
RUN set -x \
|
|
&& apk update -f \
|
|
&& apk upgrade \
|
|
&& apk --no-cache add -f bash \
|
|
coreutils \
|
|
git \
|
|
curl \
|
|
wget \
|
|
tzdata \
|
|
perl \
|
|
openssl \
|
|
nodejs \
|
|
jq \
|
|
openssh \
|
|
procps \
|
|
netcat-openbsd \
|
|
unzip \
|
|
npm \
|
|
&& rm -rf /var/cache/apk/* \
|
|
&& apk update \
|
|
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
|
&& echo "Asia/Shanghai" > /etc/timezone \
|
|
&& git config --global user.email "qinglong@users.noreply.github.com" \
|
|
&& git config --global user.name "qinglong" \
|
|
&& git config --global http.postBuffer 524288000 \
|
|
&& rm -rf /root/.cache \
|
|
&& ulimit -c 0
|
|
|
|
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 \
|
|
&& mkdir -p ${QL_DIR}/static \
|
|
&& cp -rf /static/* ${QL_DIR}/static \
|
|
&& rm -rf /static \
|
|
&& mkdir -p ${QL_DIR}/.tmp ${QL_DIR}/shell/preload \
|
|
&& chmod -R a+w ${QL_DIR}/.tmp ${QL_DIR}/shell/preload ${QL_DIR}/static
|
|
|
|
ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
|
|
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
|
|
PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3 \
|
|
PM2_HOME=${QL_DIR}/data/.pm2 \
|
|
HOME=/root
|
|
|
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin:${HOME}/bin \
|
|
NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
|
|
PIP_CACHE_DIR=${PYTHON_HOME}/pip \
|
|
PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
|
|
|
|
RUN pip3 install --prefix ${PYTHON_HOME} requests
|
|
|
|
COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
|
|
|
WORKDIR ${QL_DIR}
|
|
|
|
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
|
CMD curl -sf --noproxy '*' http://127.0.0.1:${QlPort:-5700}/api/health || exit 1
|
|
|
|
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|