HelpOps-Hub icon indicating copy to clipboard operation
HelpOps-Hub copied to clipboard

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

Open Harshit-Maurya838 opened this issue 6 months ago • 4 comments

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

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

GSSoC Participation

  • [x] I am a GSSoC'26 contributor

Harshit-Maurya838 avatar May 22 '26 03:05 Harshit-Maurya838

Hello Harshit-Maurya838, Thanks for opening an issue in HelpOps-Hub! 🚀

  • Please make sure to follow our Contributing Guidelines.

  • Hope you star our Repo.

  • Join our official Discord server, where we can collaborate and discuss how to make HelpOps-Hub even better and more professional.

  • Don’t forget to follow us on LinkedIn!

github-actions[bot] avatar May 22 '26 03:05 github-actions[bot]

@mdazfar2 Can you please assign this issue. I want to work under GSSoC'26

Harshit-Maurya838 avatar May 25 '26 06:05 Harshit-Maurya838

Hey! I'd love to take this on. I have good experience with Docker and security hardening — multi-stage builds, non-root execution, and npm ci are all patterns I've used before. Could you assign me to this issue?

PranavAgarkar07 avatar May 27 '26 02:05 PranavAgarkar07

Hi maintainers, I’d like to work on this Docker hardening task if it is available.

Plan:

  • convert the app image to a multi-stage production Dockerfile
  • use npm ci for reproducible installs
  • run the final container as a non-root user
  • keep Next standalone/output handling aligned with the repo setup
  • add/update compose docs and verify build/run commands locally

I’ll wait for official assignment before opening any PR, per the contribution rules.

saurabhhhcodes avatar May 28 '26 01:05 saurabhhhcodes

This issue has been automatically closed because it has been inactive for more than 30 days. If you believe this is still relevant, feel free to reopen it or create a new one. Thank you!

github-actions[bot] avatar Jun 28 '26 04:06 github-actions[bot]