Skip to content

[BUG] [DOCKER][SECURITY] Refactor website3.0/Dockerfile for production-grade standalone builds and non-root execution #1525

Description

@Harshit-Maurya838

Description

The current website3.0/Dockerfile has multiple production and security issues:

Identified Problems

  • Container runs as root
  • Uses npm install instead of deterministic npm ci
  • Copies entire node_modules into runtime image
  • Missing Next.js output: "standalone" optimization
  • Final image size becomes unnecessarily large (>1GB possible)

Risks

  • Increased attack surface
  • Slower CI/CD pipelines
  • Higher deployment costs
  • Non-reproducible builds
  • Elevated privilege risk during container breakout

Proposed Improvements

  • Security: Create and switch to non-root user:
    - USER node
  • Build Optimization: Enable standalone output in next.config.mjs:
    - output: "standalone"
  • Dependency Reliability
    - Replace:
    - npm install
    - with:
    - npm ci
  • Runtime Optimization: Copy only standalone artifacts instead of full node_modules.

Screenshots

No response

Any additional information?

Acceptance Criteria

  • Container runs as non-root user
  • Docker image size significantly reduced
  • npm ci used in build stage
  • Standalone Next.js build implemented
  • Multi-stage build optimized for production

What browser are you seeing the problem on?

No response

Checklist

  • I have checked the existing issues
  • I have read the Contributing Guidelines
  • I am willing to work on this issue (optional)

GSSoC Participation

  • I am a GSSoC'26 contributor

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggssoc'26

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions