Files
2026-05-16 19:03:34 +08:00

32 lines
1.0 KiB
Docker
Raw Permalink 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.
# 萌芽主页 API — 生产镜像SQLite + 静态 logo
FROM python:3.11-slim
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
RUN_MODE=production \
DATA_DIR=/app/data \
PORT=5000
# 依赖
COPY requirements.txt .
RUN pip install --no-cache-dir --no-compile -r requirements.txt
# 应用代码
COPY app.py db.py schema.sql ./
# 技术栈 SVG镜像内 ./data/logo/app/logo-dist 供 entrypoint 在「空数据卷」时复制到挂载目录
COPY data/logo ./data/logo
COPY data/logo /app/logo-dist
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh && mkdir -p /app/data/background
EXPOSE 5000
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:5000/api')" || exit 1
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["sh", "-c", "exec gunicorn --bind 0.0.0.0:${PORT:-5000} --workers 2 --threads 2 --timeout 60 --access-logfile - --error-logfile - app:app"]