From 78819990a17edebf7f50c8a5ede85ff09f7ac80f Mon Sep 17 00:00:00 2001 From: Darren <27513732@qq.com> Date: Fri, 27 Oct 2023 10:41:24 +0800 Subject: [PATCH] add update.sh --- apphub/requirements.txt | 3 +-- apphub/src/update_media.py | 12 ------------ docker/apphub/Dockerfile | 17 +++++++++++------ docker/apphub/Dockerfiledev | 4 +--- docker/apphub/config/cron | 1 + docker/apphub/config/supervisord.conf | 7 +++---- docker/apphub/{config => script}/developer.sh | 0 docker/apphub/{config => script}/entrypoint.sh | 2 +- docker/apphub/{config => script}/migration.sh | 0 docker/apphub/script/update.sh | 7 +++++++ docker/proxy/s6/README.md | 2 ++ 11 files changed, 27 insertions(+), 28 deletions(-) delete mode 100644 apphub/src/update_media.py create mode 100644 docker/apphub/config/cron rename docker/apphub/{config => script}/developer.sh (100%) rename docker/apphub/{config => script}/entrypoint.sh (95%) rename docker/apphub/{config => script}/migration.sh (100%) create mode 100644 docker/apphub/script/update.sh diff --git a/apphub/requirements.txt b/apphub/requirements.txt index 12d9f006..a612d257 100755 --- a/apphub/requirements.txt +++ b/apphub/requirements.txt @@ -5,5 +5,4 @@ keyrings.alt requests GitPython PyJWT -click -schedule \ No newline at end of file +click \ No newline at end of file diff --git a/apphub/src/update_media.py b/apphub/src/update_media.py deleted file mode 100644 index 25de36c9..00000000 --- a/apphub/src/update_media.py +++ /dev/null @@ -1,12 +0,0 @@ -import schedule -import time -import os - -def job(): - os.system("echo 'start to test schedule'") - -schedule.every(5).seconds.do(job) - -while True: - schedule.run_pending() - time.sleep(1) diff --git a/docker/apphub/Dockerfile b/docker/apphub/Dockerfile index dcd8ef48..a0eb898a 100644 --- a/docker/apphub/Dockerfile +++ b/docker/apphub/Dockerfile @@ -1,4 +1,4 @@ -# modify time: 202310270905, you can modify here to trigger Docker Build action +# modify time: 202310271039, you can modify here to trigger Docker Build action FROM python:3.10-bullseye AS buildstage LABEL maintainer="Websoft9" @@ -36,8 +36,9 @@ COPY --from=buildstage /w9library ./library COPY --from=buildstage /websoft9/apphub ./apphub COPY --from=buildstage /swagger-ui/dist ./apphub/swagger-ui COPY --from=buildstage /websoft9/apphub/src/config ./config +COPY --from=buildstage /websoft9/docker/apphub/script ./script -RUN apt update && apt install curl git jq iproute2 supervisor -y +RUN apt update && apt install curl git jq cron iproute2 supervisor -y --no-install-recommends RUN pip install --no-cache-dir --upgrade -r apphub/requirements.txt RUN pip install -e ./apphub @@ -45,9 +46,13 @@ RUN pip install -e ./apphub # supervisor COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf RUN chmod +r /etc/supervisor/conf.d/supervisord.conf -COPY config/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh -COPY config/migration.sh /migration.sh + +# cron +COPY config/cron /etc/cron.d/cron +RUN crontab /etc/cron.d/cron + +# chmod for all .sh script +RUN find /websoft9/script -name "*.sh" -exec chmod +x {} \; VOLUME /websoft9/apphub/logs VOLUME /websoft9/apphub/src/config @@ -58,4 +63,4 @@ RUN rm -rf apphub/docs apphub/tests library.zip plugin-appstore && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man /usr/share/doc /usr/share/doc-base EXPOSE 8080 -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/websoft9/script/entrypoint.sh"] \ No newline at end of file diff --git a/docker/apphub/Dockerfiledev b/docker/apphub/Dockerfiledev index 80d582c4..98c9e9f9 100644 --- a/docker/apphub/Dockerfiledev +++ b/docker/apphub/Dockerfiledev @@ -1,6 +1,4 @@ ARG APPHUB_VERSION FROM websoft9dev/apphub:${APPHUB_VERSION} as buildstage RUN mkdir -p /websoft9/apphub-dev -COPY apphub/config/developer.sh /developer.sh -RUN chmod +x /developer.sh -RUN sed -i '/supervisorctl start apphub/c\supervisorctl start apphubdev' /entrypoint.sh \ No newline at end of file +RUN sed -i '/supervisorctl start apphub/c\supervisorctl start apphubdev' /websoft9/script/entrypoint.sh \ No newline at end of file diff --git a/docker/apphub/config/cron b/docker/apphub/config/cron new file mode 100644 index 00000000..478c92ea --- /dev/null +++ b/docker/apphub/config/cron @@ -0,0 +1 @@ +* * * * * /websoft9/script/update.sh \ No newline at end of file diff --git a/docker/apphub/config/supervisord.conf b/docker/apphub/config/supervisord.conf index 33416c9a..10b622c5 100644 --- a/docker/apphub/config/supervisord.conf +++ b/docker/apphub/config/supervisord.conf @@ -17,7 +17,7 @@ stderr_logfile=/var/log/supervisord.log stderr_logfile_maxbytes=0 [program:apphubdev] -command=/developer.sh +command=/websoft9/script/developer.sh autostart=false user=root stdout_logfile=/var/log/supervisord.log @@ -25,11 +25,10 @@ stdout_logfile_maxbytes=0 stderr_logfile=/var/log/supervisord.log stderr_logfile_maxbytes=0 -[program:updatemedia] -command=/usr/local/bin/python update_media.py +[program:cron] +command=cron -f autostart=true user=root -directory=/websoft9/apphub/src stdout_logfile=/var/log/supervisord.log stdout_logfile_maxbytes=0 stderr_logfile=/var/log/supervisord.log diff --git a/docker/apphub/config/developer.sh b/docker/apphub/script/developer.sh similarity index 100% rename from docker/apphub/config/developer.sh rename to docker/apphub/script/developer.sh diff --git a/docker/apphub/config/entrypoint.sh b/docker/apphub/script/entrypoint.sh similarity index 95% rename from docker/apphub/config/entrypoint.sh rename to docker/apphub/script/entrypoint.sh index cc2ebb3a..947fe563 100644 --- a/docker/apphub/config/entrypoint.sh +++ b/docker/apphub/script/entrypoint.sh @@ -6,7 +6,7 @@ export PATH set -e -bash /migration.sh +bash /websoft9/script/migration.sh try_times=5 supervisord diff --git a/docker/apphub/config/migration.sh b/docker/apphub/script/migration.sh similarity index 100% rename from docker/apphub/config/migration.sh rename to docker/apphub/script/migration.sh diff --git a/docker/apphub/script/update.sh b/docker/apphub/script/update.sh new file mode 100644 index 00000000..12e0d171 --- /dev/null +++ b/docker/apphub/script/update.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# update media and library + +echo "Compare remote version and local version" + +echo "Download " diff --git a/docker/proxy/s6/README.md b/docker/proxy/s6/README.md index f559b64f..a94cc964 100644 --- a/docker/proxy/s6/README.md +++ b/docker/proxy/s6/README.md @@ -1,3 +1,5 @@ # S6 S6 is a mulitply process management tools at Nginx Proxy Manager. + +- nginx_proxy() at migration.sh: Migration initproxy.conf to Nginx, condition is compare Container created time and Named Volumes created time