Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using multi-stage build together with injectRestartHelper #1183

Closed
timo-klarshift opened this issue Sep 25, 2020 · 2 comments
Closed

Comments

@timo-klarshift
Copy link

timo-klarshift commented Sep 25, 2020

What happened?
I changed my image to use a multi-stage build. Using plain docker to build the image works, but using devspace to build the image it fails. Using injectRestartHelper=false works.

❯ devspace build --force-build
[info]   Building image 'app-proxy:6e0seJO' with engine 'docker'
[+] Building 0.0s (0/1)                                                                                               
[+] Building 1.8s (6/6) FINISHED                                                                                      
 => [internal] load remote build context                                                                         0.0s
 => copy /context /                                                                                              0.1s
 => resolve image config for docker.io/docker/dockerfile:1.0-experimental                                        1.0s
 => CACHED docker-image://docker.io/docker/dockerfile:1.0-experimental@sha256:cbd6491240cc8894d25e366ba83da19df  0.0s
 => CACHED [internal] helper image for file operations                                                           0.0s
 => ERROR [internal] extracting build context                                                                    0.4s
------                                                                                                                
 > [internal] extracting build context:                                                                               
#6 0.365 2020/09/25 12:09:08 exec /usr/bin/tar [tar -xvf /src/context -C /out/]                                       
#6 0.366 .dockerignore                                                                                                
<MANY FILES>
#6 0.370 yarn.lock
#6 0.370 tar: Removing leading `/' from member names
#6 0.370 /.devspace/.devspace
#6 0.370 /.devspace/.devspace/devspace-restart-helper
#6 0.370 tar: Unexpected EOF in archive
#6 0.370 tar: Unexpected EOF in archive
#6 0.370 tar: Error is not recoverable: exiting now
#6 0.372 panic: exit status 2
#6 0.372 
#6 0.372 goroutine 1 [running]:
#6 0.372 main.main()
#6 0.372 	/go/src/github.com/tonistiigi/copy/cmd/copy/main.go:57 +0x2af
------
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = failed to resolve dockerfile: rpc error: code = Unknown desc = failed to build LLB: executor failed running [copy --unpack /src/context /out/]: runc did not terminate sucessfully
[fatal]  build images: Error during image build: exit status 1

What did you expect to happen instead?
Not to fail when using injectRestartHelper=true and multi-stage build

How can we reproduce the bug? (as minimally and precisely as possible)

Any dummy package.json in $(pwd) is enough to reproduce for this Dockerfile.
I am pretty sure its due to this part somehow:

RUN \
  --mount=type=secret,id=npm,target=/app/.npmrc \  
  yarn --pure-lockfile

test.Dockerfile

# syntax = docker/dockerfile:1.0-experimental

# --- dependencies
FROM node:14-alpine as build-deps

WORKDIR /app
COPY package.json yarn.lock ./
RUN \
  --mount=type=secret,id=npm,target=/app/.npmrc \  
  yarn --pure-lockfile

# --- build app
FROM node:14-alpine as app
COPY --from=build-deps /app/node_modules /app/node_modules

USER node

ENTRYPOINT [ "docker-entrypoint.sh" ]
CMD ["npm", "run", "start:proxy"]
images:
  app:
    image: app
    preferSyncOverRebuild: true
    injectRestartHelper: true
    dockerfile: ./test.Dockerfile
    build:
      docker:
        useBuildKit: true
        skipPush: true
        options:
          target: app
        args:
          - '--secret'
          - 'id=npm,src=${USER}/.npmrc'

Local Environment:
devspace version 5.0.3
Docker version 19.03.12-ce, build 48a66213fe
linux
helm

Kubernetes Cluster:
not relevant, its just about image build

Anything else we need to know?

/kind bug

@timo-klarshift
Copy link
Author

@LukasGentele It seems I fixed it:

Following the error produced by my issue, I ended up here: moby/buildkit#958

By changing
# syntax = docker/dockerfile:1.0-experimental
to
# syntax = docker/dockerfile:1.1-experimental

I think this can be closed. I am not sure exactly what is happening under the hood. AFAIK no symlinks are used in my setup. Maybe its worth mentioning somewhere. Also where can I find released/available buildkit versions for Dockerfile? Does anybody know ?

@timo-klarshift
Copy link
Author

Solution in comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant