diff --git a/Dockerfile b/Dockerfile index 2cc5592..0b4740f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,22 @@ # КЛГ АСУ ТК — Frontend (Next.js) FROM node:20-alpine AS builder - WORKDIR /app -COPY package.json ./ -RUN npm install --production=false +COPY package.json package-lock.json ./ +RUN npm ci || npm install 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 FROM node:20-alpine AS runner WORKDIR /app ENV NODE_ENV=production - 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 - -HEALTHCHECK --interval=30s --timeout=5s \ - CMD wget -q --spider http://localhost:3000 || exit 1 - +COPY --from=builder /app/package.json ./ +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/next.config.js ./ EXPOSE 3000 CMD ["npm", "start"] diff --git a/backend/app/main.py b/backend/app/main.py index 3104415..32b4f68 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -40,8 +40,8 @@ async def lifespan(app: FastAPI): """Startup / shutdown events.""" # Create tables if they don't exist (dev only; production uses Alembic) Base.metadata.create_all(bind=engine) - # Планировщик рисков: заглушка без app; с app — см. setup_scheduler(app) при необходимости - setup_scheduler() + # Планировщик рисков (передаём app для shutdown hook) + setup_scheduler(app) yield @@ -116,6 +116,13 @@ app.add_middleware( # --------------------------------------------------------------------------- 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 # --------------------------------------------------------------------------- @@ -176,13 +183,6 @@ app.add_exception_handler(SQLAlchemyError, sqlalchemy_error_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 # --------------------------------------------------------------------------- PREFIX = settings.API_V1_PREFIX diff --git a/backend/requirements.txt b/backend/requirements.txt index 4d4958e..418ac63 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -28,6 +28,9 @@ structlog==24.4.0 # Monitoring prometheus-client==0.21.0 +# Scheduler (risk scan jobs) +APScheduler>=3.10 + # Utils python-dotenv==1.0.1 diff --git a/docker-compose.yml b/docker-compose.yml index c5fdde4..22b6d93 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ # КЛГ АСУ ТК v27 — Full Stack # docker compose up -d -version: '3.8' +# (version удалён — deprecated в Docker Compose v2+) services: # ─── Database ───────────────────────────────────