Files
diary-news/backend/Dockerfile
Mavis 60b062daf2 feat: initial MVP - FastAPI backend + Vue3 frontend + docker-compose
- backend: FastAPI + SQLAlchemy 2.0(async) + asyncpg + Alembic
- 7 API routes: auth/me/articles/sources/bookmarks/subscriptions/admin
- models: User/Source/Article/Bookmark/Subscription/ApiToken
- services: RSS fetcher (feedparser) + Tencent TMT translator with quota + cache + local NLLB fallback
- workers: APScheduler + asyncio pipeline (fetch -> dedupe -> insert -> translate)
- seed scripts: create_user, seed_sources (5 RSS: Reuters/BBC/Al Jazeera/NHK/DW)
- frontend: Vue 3 + Vite + Naive UI + Pinia + vue-router
- pages: Login, Feed (24h), ArticleDetail, Sources, Bookmarks, AdminSources
- deploy: docker-compose (postgres/redis/api/worker/frontend/caddy)
- docs: README, DEPLOY, architecture, acceptance
2026-06-07 21:51:01 +08:00

37 lines
933 B
Docker

FROM python:3.12-slim
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
TZ=Asia/Hong_Kong
# 系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
curl \
ca-certificates \
tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime \
&& echo "Asia/Hong_Kong" > /etc/timezone \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# 先装依赖(利用 Docker 缓存)
COPY pyproject.toml ./
RUN pip install --upgrade pip && \
pip install -e .
# 代码(开发期用 volume 覆盖,这里也保留一份)
COPY app ./app
COPY alembic ./alembic
COPY alembic.ini ./
EXPOSE 8000
# 默认启动 uvicorn;docker-compose 中 worker 容器会用别的 command
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]