- Use `AS builder` to compile/install dependencies
- Copy only generated artifacts `COPY --from=builder` to the final runtime image
- Exclude build tools (compilers, git, dev dependencies) from the final stage
- Separate build dependencies from runtime dependencies using `FROM ... AS build`
- Optimize caching by organizing your `COPY` commands from least frequently changed (package.json) to most (source code)
- Copy only compiled binaries or dist folders into a lightweight base image (like `-alpine` or `scratch`) for the final layer