Docker layers & build cache
Në shqip: Shtresat e Docker-it
ShpjegimiSQ
Çdo rresht i Dockerfile-it krijon një „shtresë“ që ruhet në cache. Kopjo package.json dhe instalo varësitë para se të kopjosh kodin — kështu, kur ndryshon vetëm kodi, varësitë s'instalohen sërish dhe ndërtimi zgjat sekonda.
EnglishEN
Every Dockerfile line creates a cached “layer”. Copy package.json and install dependencies before copying the code — so when only the code changes, dependencies aren't reinstalled and builds take seconds.
Si ta mendosh
Si një tortë me shtresa: ndryshon vetëm shtresën e sipërme pa e pjekur gjithë tortën sërish.
Lexoje në anglisht
Like a layer cake: change only the top layer without baking the whole cake again.
Shembull kodidockerfile
COPY package*.json ./
RUN npm ci
COPY . .