From d67c4783cf22721f85d47ff3d52e0e8af567f9d6 Mon Sep 17 00:00:00 2001 From: Rainy Date: Sun, 4 Jan 2026 16:53:26 +0800 Subject: [PATCH 1/3] feat: Add Dockerfile for application containerization, including supercronic installation and entrypoint configuration. (#1) --- Dockerfile | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000..8f320982158e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,71 @@ +FROM python:3.10-slim + +WORKDIR /app + +# Latest releases available at https://github.com/aptible/supercronic/releases +ARG TARGETARCH +ENV SUPERCRONIC_VERSION=v0.2.39 + +RUN set -ex && \ + apt-get update && \ + apt-get install -y --no-install-recommends curl ca-certificates && \ + case ${TARGETARCH} in \ + amd64) \ + export SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/${SUPERCRONIC_VERSION}/supercronic-linux-amd64; \ + export SUPERCRONIC_SHA1SUM=c98bbf82c5f648aaac8708c182cc83046fe48423; \ + export SUPERCRONIC=supercronic-linux-amd64; \ + ;; \ + arm64) \ + export SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/${SUPERCRONIC_VERSION}/supercronic-linux-arm64; \ + export SUPERCRONIC_SHA1SUM=5ef4ccc3d43f12d0f6c3763758bc37cc4e5af76e; \ + export SUPERCRONIC=supercronic-linux-arm64; \ + ;; \ + *) \ + echo "Unsupported architecture: ${TARGETARCH}"; \ + exit 1; \ + ;; \ + esac && \ + echo "Downloading supercronic for ${TARGETARCH} from ${SUPERCRONIC_URL}" && \ + # 重试机制:最多3次,每次超时30秒 + for i in 1 2 3; do \ + echo "Download attempt $i/3"; \ + if curl -fsSL --connect-timeout 30 --max-time 60 -o "$SUPERCRONIC" "$SUPERCRONIC_URL"; then \ + echo "Download successful"; \ + break; \ + else \ + echo "Download attempt $i failed"; \ + if [ $i -eq 3 ]; then \ + echo "All download attempts failed"; \ + exit 1; \ + fi; \ + sleep 2; \ + fi; \ + done && \ + echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - && \ + chmod +x "$SUPERCRONIC" && \ + mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" && \ + ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic && \ + supercronic -version && \ + apt-get remove -y curl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY docker/manage.py . +COPY trendradar/ ./trendradar/ + +# 复制 entrypoint.sh 并强制转换为 LF 格式 +COPY docker/entrypoint.sh /entrypoint.sh.tmp +RUN sed -i 's/\r$//' /entrypoint.sh.tmp && \ + mv /entrypoint.sh.tmp /entrypoint.sh && \ + chmod +x /entrypoint.sh && \ + chmod +x manage.py && \ + mkdir -p /app/config /app/output + +ENV PYTHONUNBUFFERED=1 \ + CONFIG_PATH=/app/config/config.yaml \ + FREQUENCY_WORDS_PATH=/app/config/frequency_words.txt + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file From fa7fc7c5a2ac3f6270aa8a32286b05ea535101c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=B8=85?= Date: Sun, 4 Jan 2026 17:26:18 +0800 Subject: [PATCH 2/3] build: Copy configuration directory into Docker image. --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8f320982158e1..5e09e57195533 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,6 +56,9 @@ RUN pip install --no-cache-dir -r requirements.txt COPY docker/manage.py . COPY trendradar/ ./trendradar/ +# 复制配置文件 +COPY config/ /app/config/ + # 复制 entrypoint.sh 并强制转换为 LF 格式 COPY docker/entrypoint.sh /entrypoint.sh.tmp RUN sed -i 's/\r$//' /entrypoint.sh.tmp && \ @@ -68,4 +71,4 @@ ENV PYTHONUNBUFFERED=1 \ CONFIG_PATH=/app/config/config.yaml \ FREQUENCY_WORDS_PATH=/app/config/frequency_words.txt -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/entrypoint.sh"] From d3c19d78944ce9a16de77917afdf6e8784dcc481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CRainy=E2=80=9D?= Date: Sun, 4 Jan 2026 21:25:13 +0800 Subject: [PATCH 3/3] refactor: Use relative paths for config and output directories in Dockerfile. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5e09e57195533..34557b85d4f1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ COPY docker/manage.py . COPY trendradar/ ./trendradar/ # 复制配置文件 -COPY config/ /app/config/ +COPY config/ ./config/ # 复制 entrypoint.sh 并强制转换为 LF 格式 COPY docker/entrypoint.sh /entrypoint.sh.tmp @@ -65,7 +65,7 @@ RUN sed -i 's/\r$//' /entrypoint.sh.tmp && \ mv /entrypoint.sh.tmp /entrypoint.sh && \ chmod +x /entrypoint.sh && \ chmod +x manage.py && \ - mkdir -p /app/config /app/output + mkdir -p ./config ./output ENV PYTHONUNBUFFERED=1 \ CONFIG_PATH=/app/config/config.yaml \