diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile index d052456..b2da858 100644 --- a/docker/frontend/Dockerfile +++ b/docker/frontend/Dockerfile @@ -1,11 +1,21 @@ FROM node:18-alpine as build WORKDIR /app + +# Копируем файлы package.json и package-lock.json COPY package*.json ./ + +# Устанавливаем зависимости RUN npm install + +# Копируем исходный код COPY . . + +# Собираем приложение RUN npm run build +# Настраиваем nginx FROM nginx:alpine COPY --from=build /app/dist /usr/share/nginx/html -COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker/nginx/conf.d/default.conf b/docker/nginx/conf.d/default.conf index 5c75b6d..ee3f64d 100644 --- a/docker/nginx/conf.d/default.conf +++ b/docker/nginx/conf.d/default.conf @@ -1,20 +1,28 @@ upstream backend { - server backend:8000; + server backend:8080; } server { listen 80; server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Обработка статических файлов location / { - root /usr/share/nginx/html; - index index.html; try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache"; } - location /api { - proxy_pass http://backend; + # Проксирование API запросов + location /api/ { + proxy_pass http://backend/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;