plus dockers
This commit is contained in:
parent
e350a95270
commit
484b24cd14
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@ -0,0 +1,31 @@
|
||||
# Stage 1: Сборка приложения
|
||||
FROM node:18-alpine as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем файлы package.json и package-lock.json
|
||||
COPY package*.json ./
|
||||
|
||||
# Устанавливаем зависимости
|
||||
RUN npm ci
|
||||
|
||||
# Копируем исходный код
|
||||
COPY . .
|
||||
|
||||
# Собираем приложение
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Настройка production-окружения
|
||||
FROM nginx:alpine
|
||||
|
||||
# Копируем собранные файлы из предыдущего этапа
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Копируем конфигурацию nginx
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Открываем порт 80
|
||||
EXPOSE 80
|
||||
|
||||
# Запускаем nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
@ -0,0 +1,19 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "80:80"
|
||||
restart: unless-stopped
|
||||
# Добавьте volumes если нужно хранить данные постоянно
|
||||
# volumes:
|
||||
# - ./logs:/var/log/nginx
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
21
nginx.conf
Normal file
21
nginx.conf
Normal file
@ -0,0 +1,21 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Кэширование статических файлов
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp)$ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
}
|
||||
|
||||
# Запрещаем доступ к .git и другим служебным директориям
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user