Files
telegram-shop/Dockerfile
NW ba80784ae7 security(docker): remove privileged mode, SYS_MODULE; harden WireGuard (#49 #50)
- Removed privileged: true from docker-compose.yml
- Removed SYS_MODULE cap_add (kept NET_ADMIN for WireGuard)
- Removed source code bind mounts (./src, package.json)
- Removed wg0.conf and resolv.conf bind mounts (now generated from env)
- Added resource limits: mem_limit 512m, cpus 1.0
- Added healthcheck with curl
- Added non-root user appuser:appgroup in Dockerfile
- wg0.conf now generated from env vars at container startup (WG_PRIVATE_KEY, etc.)
- resolv.conf generated from WG_DNS env var
- Rotated wg0.conf — private key removed from file
- Added WG_ALLOWED_IPS to .env.example

SECURITY: Rotate WireGuard keys on server if previously used in production
2026-06-22 01:26:35 +01:00

37 lines
1023 B
Docker
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.
FROM node:22-alpine
# Устанавливаем необходимые пакеты
RUN apk update && \
apk add --no-cache \
wireguard-tools \
iptables \
iproute2 \
openresolv \
bash \
curl && \
rm -rf /var/cache/apk/*
# Создаём непривилегированного пользователя
RUN addgroup -S appgroup && \
adduser -S appuser -G appgroup
# Рабочая директория
WORKDIR /app
# Копируем зависимости и устанавливаем их
COPY package*.json ./
RUN npm install
# Копируем исходный код с правильным владельцем
COPY --chown=appuser:appgroup ./src ./src
# Копируем скрипт запуска
COPY --chown=appuser:appgroup ./wg/start.sh /app/start.sh
RUN chmod +x /app/start.sh
# Переключаемся на непривилегированного пользователя
USER appuser
# Команда для запуска
CMD ["/bin/bash", "/app/start.sh"]