Files
push_fenxiangfengshi/Dockerfile
T

50 lines
1.9 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 丰享订单监控 —— 生产镜像
#
# 为什么用 alpine 而不是 python:3.12-slim:
# 官方 python 镜像在国内拉取经常卡在 100+MB 的层上(实测 5 分钟没下完),
# alpine 基础镜像小、且 apk 走阿里云源可在 10 秒内装好 python3 + 依赖。
# alpine:3.20 自带 python 3.12.13,与 slim 同小版本,行为一致。
# 若在国外或企业内网,改回下面注释的 slim 方案即可。
FROM alpine:3.20
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
TZ=Asia/Shanghai \
FX_DATA_DIR=/app/data \
FX_CONFIG=/app/config.yaml
# apk 走阿里云镜像(默认 dl-cdn 在国内很慢)
RUN sed -i 's#dl-cdn.alpinelinux.org#mirrors.aliyun.com#g' /etc/apk/repositories \
&& apk add --no-cache python3 py3-requests py3-yaml tzdata curl \
&& adduser -D -u 10001 app
WORKDIR /app
COPY fengxiang ./fengxiang
COPY order_monitor.py fetch_orders.py push_latest_order.py healthcheck.py ./
RUN mkdir -p /app/data && chown -R app:app /app
USER app
EXPOSE 8089
# 健康检查看的是"是否还在轮询",不是端口是否通
HEALTHCHECK --interval=60s --timeout=10s --start-period=60s --retries=3 \
CMD ["python3", "healthcheck.py"]
CMD ["python3", "order_monitor.py"]
# ---------------------------------------------------------------------------
# 备选(Debian slim + pip,需要能顺畅访问 PyPI/国内镜像):
#
# FROM python:3.12-slim
# ARG PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
# ARG PIP_TRUSTED_HOST=mirrors.aliyun.com
# RUN apt-get update && apt-get install -y --no-install-recommends tzdata ca-certificates \
# && rm -rf /var/lib/apt/lists/* && useradd --create-home --uid 10001 app
# COPY requirements.txt ./
# RUN pip install --no-cache-dir -i "$PIP_INDEX_URL" --trusted-host "$PIP_TRUSTED_HOST" -r requirements.txt
# ---------------------------------------------------------------------------