fix: AUTH_DEPENDENCY ordering, setup_scheduler(app), Dockerfile, requirements
- main.py: AUTH_DEPENDENCY определяется до первого использования (NameError fix) - main.py: setup_scheduler(app) вместо setup_scheduler() — планировщик запускается - Dockerfile (корень): multi-stage build для frontend, если отсутствует - requirements.txt: добавлен APScheduler>=3.10 - docker-compose.yml: убран deprecated version: '3.8' Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d47baa1782
commit
646401299c
19
Dockerfile
19
Dockerfile
@ -1,23 +1,22 @@
|
|||||||
# КЛГ АСУ ТК — Frontend (Next.js)
|
# КЛГ АСУ ТК — Frontend (Next.js)
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm install --production=false
|
RUN npm ci || npm install
|
||||||
COPY . .
|
COPY . .
|
||||||
|
ARG NEXT_PUBLIC_API_URL=/api/v1
|
||||||
|
ARG NEXT_PUBLIC_WS_URL=ws://backend:8000
|
||||||
|
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
||||||
|
ENV NEXT_PUBLIC_WS_URL=$NEXT_PUBLIC_WS_URL
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM node:20-alpine AS runner
|
FROM node:20-alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
COPY --from=builder /app/.next ./.next
|
COPY --from=builder /app/.next ./.next
|
||||||
COPY --from=builder /app/node_modules ./node_modules
|
|
||||||
COPY --from=builder /app/package.json ./
|
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/package.json ./
|
||||||
HEALTHCHECK --interval=30s --timeout=5s \
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
CMD wget -q --spider http://localhost:3000 || exit 1
|
COPY --from=builder /app/next.config.js ./
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
|
|||||||
@ -40,8 +40,8 @@ async def lifespan(app: FastAPI):
|
|||||||
"""Startup / shutdown events."""
|
"""Startup / shutdown events."""
|
||||||
# Create tables if they don't exist (dev only; production uses Alembic)
|
# Create tables if they don't exist (dev only; production uses Alembic)
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
# Планировщик рисков: заглушка без app; с app — см. setup_scheduler(app) при необходимости
|
# Планировщик рисков (передаём app для shutdown hook)
|
||||||
setup_scheduler()
|
setup_scheduler(app)
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
@ -116,6 +116,13 @@ app.add_middleware(
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
app.add_middleware(RequestLoggerMiddleware)
|
app.add_middleware(RequestLoggerMiddleware)
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Global authentication dependency (должно быть определено до первого include_router с dependencies=AUTH_DEPENDENCY)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
from fastapi import Depends
|
||||||
|
from app.api.deps import get_current_user
|
||||||
|
AUTH_DEPENDENCY = [Depends(get_current_user)]
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Prometheus metrics
|
# Prometheus metrics
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -176,13 +183,6 @@ app.add_exception_handler(SQLAlchemyError, sqlalchemy_error_handler)
|
|||||||
app.add_exception_handler(Exception, general_exception_handler)
|
app.add_exception_handler(Exception, general_exception_handler)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Global authentication dependency for all API routes
|
|
||||||
from app.api.deps import get_current_user
|
|
||||||
from fastapi import Depends
|
|
||||||
|
|
||||||
AUTH_DEPENDENCY = [Depends(get_current_user)]
|
|
||||||
|
|
||||||
# Routers — все API v1
|
# Routers — все API v1
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
PREFIX = settings.API_V1_PREFIX
|
PREFIX = settings.API_V1_PREFIX
|
||||||
|
|||||||
@ -28,6 +28,9 @@ structlog==24.4.0
|
|||||||
# Monitoring
|
# Monitoring
|
||||||
prometheus-client==0.21.0
|
prometheus-client==0.21.0
|
||||||
|
|
||||||
|
# Scheduler (risk scan jobs)
|
||||||
|
APScheduler>=3.10
|
||||||
|
|
||||||
# Utils
|
# Utils
|
||||||
python-dotenv==1.0.1
|
python-dotenv==1.0.1
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# КЛГ АСУ ТК v27 — Full Stack
|
# КЛГ АСУ ТК v27 — Full Stack
|
||||||
# docker compose up -d
|
# docker compose up -d
|
||||||
version: '3.8'
|
# (version удалён — deprecated в Docker Compose v2+)
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# ─── Database ───────────────────────────────────
|
# ─── Database ───────────────────────────────────
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user