Skip to main content

Infrastructure Security

This document presents the security measures applied to the FirstBreath infrastructure, following system and network administration best practices.

Security Layers Overview

1. Network Security

VPS Access Security

MeasureConfigurationDetails
SSH key-onlyPasswordAuthentication noPassword login disabled, only public key authentication allowed
Fail2bansshd jail activeAutomatic IP banning after repeated failed login attempts
Exposed ports22 (SSH), 80 (HTTP), 443 (HTTPS)All other ports are closed by firewall

Docker Network Isolation

NetworkExternal AccessRole
dokploy-networkVia Traefik onlyServices exposed to the reverse proxy
monitor-netNoVision ↔ Backend ↔ Monitoring communication
internalNoPrivate network for the Control-Hub stack

Principle: databases (MySQL, Redis) and internal services are never exposed to the Internet. Only Traefik is publicly accessible.

TLS / HTTPS

  • Certificates: Let's Encrypt (automatic generation and renewal via Certbot + Traefik)
  • Redirect: all HTTP traffic is redirected to HTTPS (redirect-to-https@file)
  • Protected domains:
    • api.firstbreath.fr — REST API and WebSocket
    • db.firstbreath.fr — CloudBeaver (DB admin)
    • sonar.firstbreath.fr — SonarQube

Exposed Ports

Only ports 80 (HTTP → redirect) and 443 (HTTPS) are publicly exposed via Traefik. Internal ports (3306 MySQL, 6379 Redis, 9090 Prometheus, etc.) are not accessible from the Internet.

2. Container Security

Non-root Users

Application containers run with non-root users where applicable:

ServiceUserUID:GID
REST API (AdonisJS)nodejs1001:1001
Frontend (my-app)nextjs1001:1001
Showcasenextjsvia addgroup/adduser
Redis Workerappuserdynamic
Camera ManagerrootGPU driver requirement
Batch InferencerootGPU driver requirement

Resource Limits

Each container has CPU and memory limits defined (see Global Architecture), preventing a compromised service from consuming all server resources.

Minimal Base Images

ImageUsageSecurity Advantage
node:20-alpineBackend (API)Reduced attack surface (minimal Alpine)
node:22-alpineFrontend, ShowcaseReduced attack surface (minimal Alpine)
python:3.11-slim-bookwormRedis WorkerLightweight image without unnecessary tools
nginx:alpineDocumentationMinimal static server
ultralytics/ultralyticsBatch InferenceGPU-specialized image (heavier, required for YOLO)
ghcr.io/firstbreath/opencv-cudaCamera ManagerCustom GPU image (CUDA + OpenCV, heavier)

Multi-stage Builds

Application Dockerfiles (API, Frontend, Showcase, Redis Worker, Documentation) use multi-stage builds: only compiled artifacts are copied into the final image. Build tools (gcc, make, python-dev) are not present in production. Vision service Dockerfiles (Camera Manager, Batch Inference) use single-stage builds due to GPU-specific base images.

3. Application Security

Dependency Auditing (CI)

EcosystemToolExecution
Node.js (npm/pnpm/yarn)pnpm audit / npm auditEvery CI pipeline
Python (pip)safety checkEvery CI pipeline (Vision)

CI pipelines fail if critical vulnerabilities are detected in dependencies.

Static Analysis (SonarQube)

SonarQube automatically detects:

  • Security Hotspots: code points requiring manual security review
  • Vulnerabilities: known security flaws (SQL injection, XSS, etc.)
  • Code smells: patterns that may lead to security issues

Code Review

  • Every Pull Request requires at least one peer review
  • Reviewer checks: business logic, test coverage, standards compliance, security
  • main branch is protected: direct merge is forbidden

4. Data Security

Database

MeasureDetails
Network accessMySQL accessible only via the internal Docker network
AuthenticationPasswords via environment variables (.env)
Persistent volumesMySQL data stored in a named Docker volume (mysql_data)
AdministrationCloudBeaver accessible only via HTTPS with authentication

Redis

MeasureDetails
Authenticationrequirepass mandatory
MemoryLimited to 256 MB with allkeys-lru eviction policy
Network accessNot publicly exposed

Secrets and Environment Variables

  • Secrets (passwords, API tokens, keys) are stored in .env files on the server
  • .env files are excluded from version control (.gitignore)
  • Sensitive variables are injected via Dokploy or Docker environment

5. Attack Protection

Denial of Service (DDoS) Attacks

MeasureDetails
Rate limitingConfigurable via Traefik middleware
Resource limitsCPU/RAM caps on each container
Redis LRUEviction policy to prevent memory exhaustion
HealthchecksAutomatic restart of failing services

Intrusions

MeasureDetails
Network isolationInternal services not accessible from the Internet
Non-root usersPrivilege limitation in case of compromise
Minimal imagesReduced attack surface
Mandatory TLSEncryption of all communications
CI auditsProactive vulnerability detection

Secure Container Registry

Custom Docker images are hosted on GitHub Container Registry (GHCR):

  • Authentication required (GitHub token)
  • Private images by default
  • Access restricted to organization members

6. Compliance and Best Practices

PracticeImplementation
Least privilegeNon-root users, resource limits
Encryption in transitTLS/HTTPS on all external communications
Defense in depthIsolated network + limited containers + CI audits + code review
Patch managementDependabot / regular Docker image updates
Environment separationSeparate Docker Compose files (dev / prod)
LoggingDocker logs accessible via docker compose logs and Grafana
MonitoringPrometheus/Grafana stack for anomaly detection