4

The context is as follows:

  • Jenkins
  • Kubernetes plugin
  • Docker-in-Docker/dind container
  • Multi-stage Dockerfile

The flow looks as follows:

  1. pull builder docker pull repo/image:builder
  2. build builder DOCKER_BUILDKIT=1 docker build . --build-arg BUILDKIT_INLINE_CACHE=1 --target builder --cache-from repo/image:builder --tag repo/image:builder
  3. push builder docker push repo/image:builder
  4. pull image docker pull repo/image:tag
  5. build image DOCKER_BUILDKIT=1 docker build . --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from repo/image:builder --cache-from repo/image:tag --tag repo/image:tag
  6. push image docker push repo/image:tag

Dockerfile:

FROM node:8.16.0 as builder

WORKDIR /app
RUN mkdir /app/frontend
COPY frontend/package.json /app/frontend/
WORKDIR /app/frontend
RUN npm install
COPY frontend /app/frontend
RUN npm run build
FROM nginx:1.13.8-alpine
WORKDIR /project/web
COPY --from=builder --chown=nginx:nginx /app/frontend/built /project/web/public

At COPY --from=builder --chown=nginx:nginx /app/frontend/built /project/web/public the docker build gets stuck forever(30-40 min after which I stop it manually) without error.

EDIT: At the first run, when images are not yet present in the registry, builder caching and COPY --from=builder works as expected. Only from the second build onwards does it get stuck at COPY --from=builder

Gabriel Stein
  • 428
  • 1
  • 4
  • 22

0 Answers0