mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
Upgrade SQLite to 1.1.5 and tar to 7.5.23 without a tar override. Update Umi, React Router, uuid, lint-staged and compatible transitive security fixes while retaining the existing ProLayout version. Constrain script file operations to checked paths, serialize Python environment values safely, and keep resource-intensive API limits with room for normal bulk use. Avoid dynamic child-process code in upgrade tests and load offline installer scripts from a fixed working directory. Cover dependency compatibility, rate limits, offline recovery and npm packaging, including the decoder patch required by existing Umi consumers.
138 lines
4.8 KiB
Docker
138 lines
4.8 KiB
Docker
# Download and verify the target Node archive without running under QEMU.
|
|
FROM --platform=$BUILDPLATFORM debian:bookworm-slim AS nodebuilder
|
|
ARG TARGETARCH
|
|
COPY docker/install-node-debian.sh /tmp/install-node-debian.sh
|
|
RUN apt-get update && \
|
|
apt-get install --no-install-recommends -y ca-certificates curl xz-utils && \
|
|
sh /tmp/install-node-debian.sh "${TARGETARCH}"
|
|
|
|
# Keep s390x on the same immutable Python base as the other Debian targets.
|
|
# The floating 3.10-slim-bookworm tag no longer includes s390x.
|
|
FROM python:3.10.19-slim-bookworm@sha256:23f63358922e79a794f71be8f3723c84e5ccca9638af3f74456dc73d6184499e AS builder
|
|
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
|
COPY patches/ /tmp/build/patches/
|
|
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
|
RUN set -x && \
|
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
apt-get update && \
|
|
apt-get install --no-install-recommends -y libatomic1 && \
|
|
npm i -g pnpm@8.3.1 && \
|
|
test "$(node --version)" = "v24.18.1" && \
|
|
cd /tmp/build && \
|
|
pnpm install --prod --frozen-lockfile
|
|
|
|
FROM python:3.10.19-slim-bookworm@sha256:23f63358922e79a794f71be8f3723c84e5ccca9638af3f74456dc73d6184499e
|
|
|
|
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.10
|
|
|
|
ENV QL_DIR=/ql \
|
|
QL_BRANCH=${QL_BRANCH} \
|
|
QL_CONTAINER=true \
|
|
LANG=C.UTF-8 \
|
|
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 && \
|
|
mkdir -p /etc/sudoers.d && \
|
|
echo 'qinglong ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/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/
|
|
|
|
RUN set -x && \
|
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
apt-get update && \
|
|
apt-get upgrade -y && \
|
|
apt-get install --no-install-recommends -y git \
|
|
curl \
|
|
wget \
|
|
tzdata \
|
|
perl \
|
|
openssl \
|
|
openssh-client \
|
|
jq \
|
|
procps \
|
|
netcat-openbsd \
|
|
sudo \
|
|
unzip \
|
|
libatomic1 && \
|
|
apt-get clean && \
|
|
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 && \
|
|
npm install -g pnpm@8.3.1 pm2 ts-node typescript@5 && \
|
|
test "$(node --version)" = "v24.18.1" && \
|
|
npm cache clean --force && \
|
|
rm -rf /root/.cache && \
|
|
rm -rf /root/.npm && \
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
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
|
|
LABEL org.opencontainers.image.revision=${SOURCE_COMMIT}
|
|
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \
|
|
&& cd ${QL_DIR} \
|
|
&& if [ -n "${SOURCE_COMMIT}" ]; then git fetch --depth=1 origin "${SOURCE_COMMIT}" && git reset --hard FETCH_HEAD; fi \
|
|
&& cp -f .env.example .env \
|
|
&& chmod 777 ${QL_DIR}/shell/*.sh \
|
|
&& chmod 777 ${QL_DIR}/docker/*.sh
|
|
|
|
# Downloaded by CI from the build-static job in this workflow run.
|
|
COPY --chown=qinglong:qinglong static/ /ql/static/
|
|
COPY docker/verify-build.cjs docker/build-manifest.cjs /tmp/
|
|
COPY --from=builder /tmp/build/pnpm-lock.yaml /tmp/dependency-lock.yaml
|
|
RUN cd ${QL_DIR} && node /tmp/verify-build.cjs /tmp/dependency-lock.yaml
|
|
|
|
ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
|
|
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
|
|
PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3 \
|
|
HOME=/home/qinglong
|
|
|
|
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 \
|
|
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 --chown=qinglong:qinglong --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
|
|
|
USER root
|
|
|
|
RUN ln -sf ${QL_DIR}/shell/task.sh /usr/local/bin/task \
|
|
&& ln -sf ${QL_DIR}/shell/update.sh /usr/local/bin/ql \
|
|
&& chmod +x /usr/local/bin/task /usr/local/bin/ql
|
|
|
|
WORKDIR ${QL_DIR}
|
|
|
|
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
|
CMD curl -sf --noproxy '*' http://localhost:${QlPort:-5700}/api/health || exit 1
|
|
|
|
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
|
|
|
VOLUME /ql/data
|
|
|
|
EXPOSE 5700
|