From 7d6a424c8d9f36a162d5b14603231d9b05892eda Mon Sep 17 00:00:00 2001 From: MoonTestUse1 Date: Mon, 23 Dec 2024 23:19:10 +0600 Subject: [PATCH] change docker --- docker-compose.yml | 12 ++++-------- docker/backend/Dockerfile | 8 +++++--- docker/frontend/Dockerfile | 19 +++++++++---------- docker/nginx/conf.d/default.conf | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4cbefdf..63866cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,14 +3,12 @@ version: '3.8' services: frontend: build: - context: ./frontend - dockerfile: ../docker/frontend/Dockerfile + context: . + dockerfile: docker/frontend/Dockerfile container_name: support-frontend restart: unless-stopped depends_on: - backend - volumes: - - frontend_build:/app/dist backend: build: @@ -20,9 +18,8 @@ services: restart: unless-stopped environment: - TELEGRAM_BOT_TOKEN=7677506032:AAHEqNUr1lIUfNVbLwaWIaPeKKShsCyz3eo - - TELEGRAM_CHAT_ID=-1002037023574 + - TELEGRAM_CHAT_ID=5057752127 volumes: - - ./backend:/app - sqlite_data:/app/instance nginx: @@ -34,11 +31,10 @@ services: volumes: - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./docker/nginx/conf.d:/etc/nginx/conf.d:ro - - frontend_build:/usr/share/nginx/html:ro + - ./frontend/dist:/usr/share/nginx/html:ro depends_on: - frontend - backend volumes: sqlite_data: - frontend_build: diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile index a9a13da..53f6cd9 100644 --- a/docker/backend/Dockerfile +++ b/docker/backend/Dockerfile @@ -6,9 +6,11 @@ RUN apt-get update && apt-get install -y \ gcc \ && rm -rf /var/lib/apt/lists/* -COPY backend/requirements.txt . +# Copy requirements first for better caching +COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY backend . +# Copy the rest of the application +COPY . . -CMD ["python", "run.py"] \ No newline at end of file +CMD ["python", "run.py"] diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile index 8864ace..a641559 100644 --- a/docker/frontend/Dockerfile +++ b/docker/frontend/Dockerfile @@ -1,19 +1,18 @@ -FROM node:18-alpine as build +FROM node:18-alpine WORKDIR /app -# Копируем файлы package.json и package-lock.json -COPY package*.json ./ +# Copy package files +COPY frontend/package*.json ./ -# Устанавливаем зависимости +# Install dependencies RUN npm install -# Копируем исходный код -COPY . . +# Copy source code +COPY frontend/ . -# Собираем приложение +# Build the app RUN npm run build -# Этап копирования -FROM scratch -COPY --from=build /app/dist /dist +# Keep container running and serve the built files +CMD ["npm", "run", "preview"] diff --git a/docker/nginx/conf.d/default.conf b/docker/nginx/conf.d/default.conf index 88efcb0..42716fa 100644 --- a/docker/nginx/conf.d/default.conf +++ b/docker/nginx/conf.d/default.conf @@ -1,5 +1,5 @@ upstream backend { - server backend:8000; # Изменено с 8080 на 8000 + server backend:8000; # Changed from 8080 to 8000 } server {