I'm building a Docker Image on Pull Requests in my GitOps setup. The images are built and pushed to Azure Registry. Often, it's only a small update in the code, and if I could reuse the layers from the previous build (pushed to Azure Registry), I could save a lot of time.

As shown in Dockerfile, yarn install could be skipped, since new changes occur in the COPY statement below it only:

FROM node:16

# create dirs and chown
RUN mkdir -p /usr/src/node-app && chown -R node:node /usr/src/node-app

WORKDIR /usr/src/node-app

COPY package.json yarn.lock tsconfig.json ./

USER node

# install node modules
RUN yarn install --pure-lockfile

# ensure ownership
COPY --chown=node:node . .

# set default env
RUN mv .env.example .env


# entrypoint is node
# see https://github.com/nodejs/docker-node/blob/main/docker-entrypoint.sh

# default command: prod start
CMD ["yarn", "start"]

How can I download the previous image from Azure Registry and use the layers there? Simply downloading the previous image (with different tag) does not seem to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.