Layer order

2 snippets across 2 stacks — Docker, HTML & CSS

DKDocker

Accidental Build Cache Invalidation

DK · Common Mistakes
syntax
# Problem — COPY . . before RUN npm ci
COPY . .
RUN npm ci
example
# Every source code change re-runs npm ci (~30-60 seconds).
# Fix — copy manifests first:
COPY package.json package-lock.json ./
RUN npm ci
COPY . .

Note Docker invalidates a layer's cache when any input changes. A broad COPY . . changes whenever ANY file in your project changes, nuking the cache for all subsequent layers. Order Dockerfile instructions from least-frequently to most-frequently changing.

HCHTML & CSS

Z-Index & Stacking

HC · Layout & Positioning
syntax
z-index: integer;
example
.dropdown   { z-index: 10; }
.modal-bg   { z-index: 40; }
.modal      { z-index: 50; }
.toast      { z-index: 60; }

/* Isolate stacking context */
.component {
  isolation: isolate;
}

Note z-index only works on positioned elements (relative, absolute, fixed, sticky) and flex/grid children. Elements with opacity < 1, transform, or filter create new stacking contexts. Use isolation: isolate to explicitly create one without side effects.