增加 debian-slim 基础镜像

This commit is contained in:
whyour 2023-05-12 14:18:22 +08:00
parent fa3eb5f656
commit dcd93f930d
6 changed files with 115 additions and 121 deletions

View File

@ -5,8 +5,9 @@ on:
paths-ignore: paths-ignore:
- "*.md" - "*.md"
branches: branches:
- "master" - 'master'
- "develop" - 'develop'
- 'debian'
tags: tags:
- "v*" - "v*"
schedule: schedule:
@ -176,15 +177,14 @@ jobs:
QL_BRANCH=${{ github.ref_name }} QL_BRANCH=${{ github.ref_name }}
SOURCE_COMMIT=${{ github.sha }} SOURCE_COMMIT=${{ github.sha }}
network: host network: host
# linux/s390x npm 暂不可用 platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/386
context: . context: .
file: ./docker/Dockerfile file: ./docker/Dockerfile
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=whyour/qinglong:cache cache-from: type=registry,ref=whyour/qinglong:cache-debian
cache-to: type=registry,ref=whyour/qinglong:cache,mode=max cache-to: type=registry,ref=whyour/qinglong:cache-debian,mode=max
- name: Image digest - name: Image digest
run: | run: |
@ -242,8 +242,7 @@ jobs:
QL_BRANCH=${{ github.ref_name }} QL_BRANCH=${{ github.ref_name }}
SOURCE_COMMIT=${{ github.sha }} SOURCE_COMMIT=${{ github.sha }}
network: host network: host
# linux/s390x npm 暂不可用 platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/386
context: . context: .
file: ./docker/310.Dockerfile file: ./docker/310.Dockerfile
push: true push: true

View File

@ -58,7 +58,7 @@ export default class CronService {
return doc; return doc;
} }
if (this.isNodeCron(doc) && !this.isSpecialSchedule(doc.schedule)) { if (!this.isSpecialSchedule(doc.schedule)) {
await cronClient.addCron([ await cronClient.addCron([
{ {
name: doc.name || '', name: doc.name || '',
@ -88,11 +88,9 @@ export default class CronService {
return newDoc; return newDoc;
} }
if (this.isNodeCron(doc)) { await cronClient.delCron([String(newDoc.id)]);
await cronClient.delCron([String(doc.id)]);
}
if (this.isNodeCron(newDoc) && !this.isSpecialSchedule(newDoc.schedule)) { if (!this.isSpecialSchedule(newDoc.schedule)) {
await cronClient.addCron([ await cronClient.addCron([
{ {
name: doc.name || '', name: doc.name || '',
@ -532,20 +530,19 @@ export default class CronService {
public async enabled(ids: number[]) { public async enabled(ids: number[]) {
await CrontabModel.update({ isDisabled: 0 }, { where: { id: ids } }); await CrontabModel.update({ isDisabled: 0 }, { where: { id: ids } });
const docs = await CrontabModel.findAll({ where: { id: ids } }); const docs = await CrontabModel.findAll({ where: { id: ids } });
const sixCron = docs const crons = docs.map((doc) => ({
.filter((x) => this.isNodeCron(x) && !this.isSpecialSchedule(x.schedule)) name: doc.name || '',
.map((doc) => ({ id: String(doc.id),
name: doc.name || '', schedule: doc.schedule!,
id: String(doc.id), command: this.makeCommand(doc),
schedule: doc.schedule!, extra_schedules: doc.extra_schedules || [],
command: this.makeCommand(doc), }));
extra_schedules: doc.extra_schedules || [],
}));
if (isDemoEnv()) { if (isDemoEnv()) {
return; return;
} }
await cronClient.addCron(sixCron);
await cronClient.addCron(crons);
await this.setCrontab(); await this.setCrontab();
} }
@ -638,7 +635,6 @@ export default class CronService {
await writeFileWithLock(config.crontabFile, crontab_string); await writeFileWithLock(config.crontabFile, crontab_string);
execSync(`crontab ${config.crontabFile}`);
await CrontabModel.update({ saved: true }, { where: {} }); await CrontabModel.update({ saved: true }, { where: {} });
} }
@ -679,12 +675,7 @@ export default class CronService {
public async autosave_crontab() { public async autosave_crontab() {
const tabs = await this.crontabs(); const tabs = await this.crontabs();
const regularCrons = tabs.data const regularCrons = tabs.data
.filter( .filter((x) => x.isDisabled !== 1 && !this.isSpecialSchedule(x.schedule))
(x) =>
x.isDisabled !== 1 &&
this.isNodeCron(x) &&
!this.isSpecialSchedule(x.schedule),
)
.map((doc) => ({ .map((doc) => ({
name: doc.name || '', name: doc.name || '',
id: String(doc.id), id: String(doc.id),

View File

@ -1,13 +1,18 @@
FROM python:3.10-alpine3.18 AS builder FROM node:20-slim AS nodebuilder
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.10-alpine FROM python:3.10-slim-bullseye AS builder
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
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 update && \
apt install --no-install-recommends -y libatomic1 && \
npm i -g pnpm@8.3.1 && \
cd /tmp/build && \
pnpm install --prod
FROM python:3.10-slim-bullseye
ARG QL_MAINTAINER="whyour" ARG QL_MAINTAINER="whyour"
LABEL maintainer="${QL_MAINTAINER}" LABEL maintainer="${QL_MAINTAINER}"
@ -21,52 +26,47 @@ ENV QL_DIR=/ql \
SHELL=/bin/bash \ SHELL=/bin/bash \
PS1="\u@\h:\w \$ " PS1="\u@\h:\w \$ "
VOLUME /ql/data COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
EXPOSE 5700
COPY --from=builder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/ RUN set -x && \
COPY --from=builder /usr/local/bin/. /usr/local/bin/ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
apt update && \
RUN set -x \ apt upgrade -y && \
&& apk update -f \ apt install --no-install-recommends -y git \
&& apk upgrade \
&& apk --no-cache add -f bash \
coreutils \
git \
curl \ curl \
wget \ wget \
tzdata \ tzdata \
perl \ perl \
openssl \ openssl \
openssh-client \
nginx \ nginx \
nodejs \
jq \ jq \
openssh \
procps \ procps \
netcat-openbsd \ netcat \
unzip \ unzip \
npm \ libatomic1 && \
&& rm -rf /var/cache/apk/* \ apt clean && \
&& apk update \ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ echo "Asia/Shanghai" >/etc/timezone && \
&& echo "Asia/Shanghai" > /etc/timezone \ git config --global user.email "qinglong@users.noreply.github.com" && \
&& git config --global user.email "qinglong@users.noreply.github.com" \ git config --global user.name "qinglong" && \
&& git config --global user.name "qinglong" \ git config --global http.postBuffer 524288000 && \
&& git config --global http.postBuffer 524288000 \ npm install -g pnpm@8.3.1 pm2 ts-node && \
&& rm -rf /root/.cache \ rm -rf /root/.cache && \
&& ulimit -c 0 rm -rf /root/.npm && \
ulimit -c 0
ARG SOURCE_COMMIT ARG SOURCE_COMMIT
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \ RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
&& cd ${QL_DIR} \ cd ${QL_DIR} && \
&& cp -f .env.example .env \ cp -f .env.example .env && \
&& chmod 777 ${QL_DIR}/shell/*.sh \ chmod 777 ${QL_DIR}/shell/*.sh && \
&& chmod 777 ${QL_DIR}/docker/*.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 /static && \
&& mkdir -p ${QL_DIR}/static \ mkdir -p ${QL_DIR}/static && \
&& cp -rf /static/* ${QL_DIR}/static \ cp -rf /static/* ${QL_DIR}/static && \
&& rm -rf /static rm -rf /static
ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \ ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \ PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
@ -87,3 +87,7 @@ HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
CMD curl -sf --noproxy '*' http://127.0.0.1:5600/api/health || exit 1 CMD curl -sf --noproxy '*' http://127.0.0.1:5600/api/health || exit 1
ENTRYPOINT ["./docker/docker-entrypoint.sh"] ENTRYPOINT ["./docker/docker-entrypoint.sh"]
VOLUME /ql/data
EXPOSE 5700

View File

@ -1,13 +1,18 @@
FROM python:3.11-alpine3.18 AS builder FROM node:20-slim AS nodebuilder
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 FROM python:3.11-slim AS builder
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
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 update && \
apt install --no-install-recommends -y libatomic1 && \
npm i -g pnpm@8.3.1 && \
cd /tmp/build && \
pnpm install --prod
FROM python:3.11-slim
ARG QL_MAINTAINER="whyour" ARG QL_MAINTAINER="whyour"
LABEL maintainer="${QL_MAINTAINER}" LABEL maintainer="${QL_MAINTAINER}"
@ -21,52 +26,43 @@ ENV QL_DIR=/ql \
SHELL=/bin/bash \ SHELL=/bin/bash \
PS1="\u@\h:\w \$ " PS1="\u@\h:\w \$ "
VOLUME /ql/data COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
EXPOSE 5700
COPY --from=builder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/ RUN set -x && \
COPY --from=builder /usr/local/bin/. /usr/local/bin/ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
apt update && \
RUN set -x \ apt upgrade -y && \
&& apk update -f \ apt install --no-install-recommends -y git \
&& apk upgrade \
&& apk --no-cache add -f bash \
coreutils \
git \
curl \ curl \
wget \ wget \
tzdata \
perl \
openssl \
nginx \ nginx \
nodejs \
jq \ jq \
openssh \
procps \ procps \
netcat-openbsd \ netcat \
unzip \ unzip \
npm \ libatomic1 && \
&& rm -rf /var/cache/apk/* \ apt clean && \
&& apk update \ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ echo "Asia/Shanghai" >/etc/timezone && \
&& echo "Asia/Shanghai" > /etc/timezone \ git config --global user.email "qinglong@users.noreply.github.com" && \
&& git config --global user.email "qinglong@users.noreply.github.com" \ git config --global user.name "qinglong" && \
&& git config --global user.name "qinglong" \ git config --global http.postBuffer 524288000 && \
&& git config --global http.postBuffer 524288000 \ npm install -g pnpm@8.3.1 pm2 ts-node && \
&& rm -rf /root/.cache \ rm -rf /root/.cache && \
&& ulimit -c 0 rm -rf /root/.npm && \
ulimit -c 0
ARG SOURCE_COMMIT ARG SOURCE_COMMIT
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \ RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
&& cd ${QL_DIR} \ cd ${QL_DIR} && \
&& cp -f .env.example .env \ cp -f .env.example .env && \
&& chmod 777 ${QL_DIR}/shell/*.sh \ chmod 777 ${QL_DIR}/shell/*.sh && \
&& chmod 777 ${QL_DIR}/docker/*.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 /static && \
&& mkdir -p ${QL_DIR}/static \ mkdir -p ${QL_DIR}/static && \
&& cp -rf /static/* ${QL_DIR}/static \ cp -rf /static/* ${QL_DIR}/static && \
&& rm -rf /static rm -rf /static
ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \ ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \ PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
@ -87,3 +83,7 @@ HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
CMD curl -sf --noproxy '*' http://127.0.0.1:5600/api/health || exit 1 CMD curl -sf --noproxy '*' http://127.0.0.1:5600/api/health || exit 1
ENTRYPOINT ["./docker/docker-entrypoint.sh"] ENTRYPOINT ["./docker/docker-entrypoint.sh"]
VOLUME /ql/data
EXPOSE 5700

View File

@ -39,6 +39,6 @@ fi
log_with_style "SUCCESS" "🎉 容器启动成功!" log_with_style "SUCCESS" "🎉 容器启动成功!"
crond -f >/dev/null tail -f /dev/null
exec "$@" exec "$@"

View File

@ -9,7 +9,7 @@ else
fi fi
echo -e "\n1、安装bot依赖...\n" echo -e "\n1、安装bot依赖...\n"
apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev apt install -y gcc python3-dev musl-dev
echo -e "\nbot依赖安装成功...\n" echo -e "\nbot依赖安装成功...\n"
echo -e "2、下载bot所需文件...\n" echo -e "2、下载bot所需文件...\n"