Skip to content

[proposal] Eliminate the source-code copy into emptyDir on webserver start (investigation) #34

Description

@henzigo

Context

Every webserver pod start copies the whole application source from the image into an emptyDir
(cp -r -n /var/www/html/. /tmp/source-codes) so the nginx sidecar can serve the same files.
Cost: tens of seconds of startup, duplicated disk usage on the node, and the init container
is pure overhead — the code is already in the image.

Proposal (investigation)

Evaluate alternatives to the copy:

  • A: multi-stage build that puts the static/public assets into the nginx image — nginx
    serves its own copy, php-fpm serves from its image, no shared volume at all
  • B: nginx sidecar runs the application image with an nginx binary (single image, no copy)
  • C: keep the shared volume but populate it via an image subPath-style approach /
    readOnly bind of the image filesystem (not natively supported — likely rejected)
  • D: status quo + medium: Memory and/or sizeLimit as micro-optimizations

Constraint: must keep the "symlink switch" deploy semantics the app relies on
($realpath_root in the nginx config) — verify with the application team.

Deliverable: decision record; implementation follow-up depends on project-base image changes.

Tasks

  • Measure current copy cost on a real project (startup time, bytes)
  • Prototype option A or B
  • Decision record

Related: #26 (warmup init container)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/app-chartshopsys-app chart (workloads, ingresses, secrets, hooks)enhancementNew feature or requestinvestigationresearch/PoC, outcome is a decision recordpriority/low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions