uchill/DOCKER-SERVER-CONFIG.md

63 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Конфигурация Docker на сервере
## Рекомендации для серверов с ограниченной RAM (8 GB)
### 1. Ограничение BuildKit cache
Чтобы BuildKit cache не раздувался до 80+ GB:
```bash
# Создать или отредактировать
sudo nano /etc/docker/daemon.json
```
Содержимое:
```json
{
"builder": {
"gc": {
"defaultKeepStorage": "10GB",
"enabled": true
}
},
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
```
Затем перезапуск:
```bash
sudo systemctl restart docker
```
### 2. Очистка build cache
Если нужно освободить место вручную:
```bash
# Удалить неиспользуемый build cache (осторожно: следующая сборка будет дольше)
docker builder prune -af
# Или с ограничением по возрасту (старше 7 дней)
docker builder prune -af --filter "until=168h"
```
### 3. Frontend Dockerfile — лимит памяти Node.js
В `front_material/Dockerfile` уже задано:
```dockerfile
ENV NODE_OPTIONS="--max-old-space-size=2048"
```
Это ограничивает heap Node.js до 2 GB при сборке и снижает риск OOM и тяжёлого swapping на машинах с 8 GB RAM.
### 4. Swap
Рекомендуется swap 48 GB на серверах с 8 GB RAM — для стабильности при пиковых нагрузках.