From 876abdfc86540320f3c0ef8e9d2187660bf63af1 Mon Sep 17 00:00:00 2001 From: MoonTestUse1 Date: Mon, 23 Dec 2024 23:40:31 +0600 Subject: [PATCH] change docker --- backend/app/main.py | 16 +++++++++++++--- docker-compose.yml | 2 ++ docker/frontend/Dockerfile | 4 ++++ docker/nginx/conf.d/default.conf | 10 ++-------- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index 98f2782..8ddf720 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -28,13 +28,23 @@ bot_thread.start() # CORS middleware app.add_middleware( - CORSMiddleware, - allow_origins=["*"], + CORSMiddleware, + allow_origins=[ + "http://localhost:5173", + "http://185.139.70.62:5173", + "http://46.233.242.206:5173", + "http://185.139.70.62", + "http://46.233.242.206", + "http://0.0.0.0", + ], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) - +app.include_router(auth.router, prefix="/api") +app.include_router(employees.router, prefix="/api") +app.include_router(requests.router, prefix="/api") +app.include_router(statistics.router, prefix="/api") # Auth endpoints @app.post("/api/auth/login") diff --git a/docker-compose.yml b/docker-compose.yml index f12d6d0..481a025 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,8 @@ services: environment: - TELEGRAM_BOT_TOKEN=7677506032:AAHEqNUr1lIUfNVbLwaWIaPeKKShsCyz3eo - TELEGRAM_CHAT_ID=-1002037023574 + volumes: + - sqlite_data:/app/instance nginx: image: nginx:alpine diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile index f814649..39dda1d 100644 --- a/docker/frontend/Dockerfile +++ b/docker/frontend/Dockerfile @@ -3,11 +3,15 @@ FROM node:18-alpine as build WORKDIR /app +# Copy package files COPY package*.json ./ RUN npm install +# Copy source code and build COPY . . RUN npm run build +# Production stage FROM nginx:alpine COPY --from=build /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/docker/nginx/conf.d/default.conf b/docker/nginx/conf.d/default.conf index 3f6f8b0..d06cf2e 100644 --- a/docker/nginx/conf.d/default.conf +++ b/docker/nginx/conf.d/default.conf @@ -1,6 +1,6 @@ # docker/nginx/conf.d/default.conf upstream backend { - server backend:8000; # Change port to match FastAPI default + server backend:8000; } server { @@ -18,7 +18,7 @@ server { # Proxy API requests location /api/ { - proxy_pass http://backend/; # Remove /api/ from proxy_pass + proxy_pass http://backend/api/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; @@ -28,10 +28,4 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } - - # Handle favicon - location = /favicon.ico { - access_log off; - log_not_found off; - } }