From 4c3c1bfc6d566e1a9ea4caf266e889edcbcd44b2 Mon Sep 17 00:00:00 2001 From: MoonTestUse1 Date: Mon, 23 Dec 2024 23:34:41 +0600 Subject: [PATCH] change docker --- backend/run.py | 2 +- docker-compose.yml | 13 +++++-------- docker/frontend/Dockerfile | 12 +++--------- docker/nginx/conf.d/default.conf | 12 +++++++----- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/backend/run.py b/backend/run.py index cb79509..227ba7c 100644 --- a/backend/run.py +++ b/backend/run.py @@ -17,7 +17,7 @@ async def run_bot(): async def run_api(): """Run FastAPI application""" - config = uvicorn.Config(app, host=["localhost", "185.139.70.62", "46.233.242.206"], port=8080, reload=True) + config = uvicorn.Config(app, host=["0.0.0.0"], port=8000, reload=True) server = uvicorn.Server(config) try: await server.serve() diff --git a/docker-compose.yml b/docker-compose.yml index a58030f..f12d6d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,8 +7,6 @@ services: dockerfile: ../docker/frontend/Dockerfile container_name: support-frontend restart: unless-stopped - depends_on: - - backend backend: build: @@ -18,18 +16,17 @@ services: restart: unless-stopped environment: - TELEGRAM_BOT_TOKEN=7677506032:AAHEqNUr1lIUfNVbLwaWIaPeKKShsCyz3eo - - TELEGRAM_CHAT_ID=5057752127 - volumes: - - sqlite_data:/app/instance + - TELEGRAM_CHAT_ID=-1002037023574 nginx: - build: - context: ./frontend - dockerfile: ../docker/frontend/Dockerfile + image: nginx:alpine container_name: support-nginx restart: unless-stopped ports: - "80:80" + volumes: + - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./docker/nginx/conf.d:/etc/nginx/conf.d:ro depends_on: - frontend - backend diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile index a6c34d9..f814649 100644 --- a/docker/frontend/Dockerfile +++ b/docker/frontend/Dockerfile @@ -1,19 +1,13 @@ -FROM node:18-alpine as builder +# docker/frontend/Dockerfile +FROM node:18-alpine as build WORKDIR /app -# Copy package files COPY package*.json ./ - -# Install dependencies RUN npm install -# Copy source code COPY . . - -# Build the app RUN npm run build -# Production stage FROM nginx:alpine -COPY --from=builder /app/dist /usr/share/nginx/html +COPY --from=build /app/dist /usr/share/nginx/html diff --git a/docker/nginx/conf.d/default.conf b/docker/nginx/conf.d/default.conf index 708f609..3f6f8b0 100644 --- a/docker/nginx/conf.d/default.conf +++ b/docker/nginx/conf.d/default.conf @@ -1,5 +1,6 @@ +# docker/nginx/conf.d/default.conf upstream backend { - server backend:8000; # Changed from 8080 to match FastAPI port + server backend:8000; # Change port to match FastAPI default } server { @@ -9,14 +10,15 @@ server { root /usr/share/nginx/html; index index.html; - # Fix permissions and routing + # Handle SPA routing location / { - try_files $uri $uri/ /index.html =404; + try_files $uri $uri/ /index.html; add_header Cache-Control "no-cache"; } + # Proxy API requests location /api/ { - proxy_pass http://backend/api/; + proxy_pass http://backend/; # Remove /api/ from proxy_pass proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; @@ -27,7 +29,7 @@ server { proxy_set_header X-Forwarded-Proto $scheme; } - # Add explicit favicon handling + # Handle favicon location = /favicon.ico { access_log off; log_not_found off;