Skip to content

[DevOps] Docker Multi-Stage Production Build Optimization & Security Hardening #1335

Description

@blurbeast

Overview & Background

Production Docker containers for FlowFi backend and frontend must be lightweight, fast to build, and hardened against container breakout vulnerabilities.


Technical Specification & Architecture

  1. Backend Dockerfile Optimization (backend/Dockerfile):
    • Multi-stage build (Builder -> Production Runner).
    • Use minimal node:20-alpine base image.
    • Execute under non-root node user (USER node).
    • Reduce image size from $> 800\text{MB}$ to $< 150\text{MB}$.
  2. Frontend Dockerfile Optimization (frontend/Dockerfile):
    • Next.js standalone output build (output: 'standalone' in next.config.ts).
    • Image size reduction to $< 120\text{MB}$.
  3. Health Check Probes:
    • Add native Docker healthcheck instructions calling /health.

Target Files

  • backend/Dockerfile
  • frontend/Dockerfile
  • docker-compose.yml

Acceptance Criteria

  • Docker container images build cleanly with $< 150\text{MB}$ final size.
  • Containers run as non-root user.
  • Healthcheck probes report healthy status in container orchestrators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    devopsInfrastructure and CI/CDdockerPull requests that update docker codedrips-waveproductionsecuritySecurity related tasks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions