ledermann/docker-rails-base

Not compatible with BuildKit

maxime-carbonneau opened this issue · 8 comments

Since the update to engine 20.10, I can no longer use :

FROM ledermann/rails-base-builder:2.7.2-alpine AS Builder
FROM ledermann/rails-base-final:2.7.2-alpine

It seems to me that rails-base-builder is never executed.

For me it works fine with Docker 20.10.0 on MacOS and Ubuntu. Do you get an error message?

Here is an example of a docker build . for one of my applications:

~/Projects/foo on master > docker -v
Docker version 20.10.0, build 7287ab3

~/Projects/foo on master > docker build .
Sending build context to Docker daemon  1.139MB
Step 1/7 : FROM ledermann/rails-base-builder:2.7.2-alpine AS Builder
# Executing 7 build triggers
 ---> Running in 00852304ff82
[...]
Fetching gem metadata from https://rubygems.org/............
[...]
Bundle complete! 28 Gemfile dependencies, 64 gems now installed.
Gems in the groups development and test were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
[...]
 ---> Running in 2a9ca1352527
Removing intermediate container 2a9ca1352527
 ---> Running in 0f1a04801039
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 13.26s.
Compiling...
Compiled all packs in /app/public/packs
Hash: d2a0e3203cad58a954a2
Version: webpack 4.44.2
Time: 37224ms
Built at: 12/15/2020 2:43:44 AM
[...]
yarn install v1.22.4
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.03s.
Removing intermediate container 0f1a04801039
 ---> Running in f23a0105b844
Removing intermediate container f23a0105b844
 ---> Running in 9d6e4087dc6c
Removing intermediate container 9d6e4087dc6c
 ---> 90bfabc727db
Step 2/7 : RUN rm .browserslistrc babel.config.js package.json postcss.config.js yarn.lock
 ---> Running in e3fc822b5c05
Removing intermediate container e3fc822b5c05
 ---> e46e2b183830
Step 3/7 : FROM ledermann/rails-base-final:2.7.2-alpine
# Executing 7 build triggers
 ---> Running in a0c2777c94db
Removing intermediate container a0c2777c94db
 ---> Running in aac170a2549c
Removing intermediate container aac170a2549c
 ---> Running in 33b7e2c77362
Removing intermediate container 33b7e2c77362
 ---> Running in 4a53f42fcc60
Removing intermediate container 4a53f42fcc60
 ---> Running in 6a5b32237263
Removing intermediate container 6a5b32237263
 ---> fff123fc24a3
Step 4/7 : LABEL maintainer="georg@ledermann.dev"
 ---> Running in 1338f373d815
Removing intermediate container 1338f373d815
 ---> e3f6c051cceb
Step 5/7 : RUN apk add --no-cache vips
 ---> Running in 787e41e3c162
[...]
OK: 76 MiB in 89 packages
Removing intermediate container 787e41e3c162
 ---> a8d4cc00e422
Step 6/7 : USER app
 ---> Running in 20cf1bc739b8
Removing intermediate container 20cf1bc739b8
 ---> becf12048c2c
Step 7/7 : CMD ["docker/startup.sh"]
 ---> Running in e9e29bfc03cf
Removing intermediate container e9e29bfc03cf
 ---> 422b2de1163e
Successfully built 422b2de1163e

I'm using MacOS 10.15.7

$> docker -v
Docker version 20.10.0, build 7287ab3
$> docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.4
 Version:           20.10.0
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        7287ab3
 Built:             Tue Dec  8 18:55:43 2020
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.0
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       eeddea2
  Built:            Tue Dec  8 18:58:04 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

I used to have the same output as you, but since I updated to Docker Desktop 3.0.1 I get

$> docker build .
[+] Building 1.3s (9/9) FINISHED
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 37B
=> [internal] load .dockerignore
=> => transferring context: 2B
=> [internal] load metadata for docker.io/ledermann/rails-base-final:2.7.2-alpine
=> [stage-1 1/1] FROM docker.io/ledermann/rails-base-final:2.7.2-alpine@sha256:f21401e1c216ce8e705f0a53808545b0602de71fc5fb1a4d83572e5c13d0fd1c
=> [builder 1/1] FROM docker.io/ledermann/rails-base-builder:2.7.2-alpine
=> => resolve docker.io/ledermann/rails-base-builder:2.7.2-alpine
=> CACHED [stage-1 2/1] RUN addgroup -g 1000 -S app &&             adduser -u 1000 -S app -G app
=> CACHED [stage-1 3/1] COPY --from=Builder --chown=app:app /usr/local/bundle/ /usr/local/bundle/
=> CACHED [stage-1 4/1] COPY --from=Builder --chown=app:app /app /app
=> exporting to image
=> => exporting layers
=> => writing image sha256:7ec68f3d66280bf36dc829e976361da027c28ac0db9d68a340077c0f272963ae

I tried with only

FROM ledermann/rails-base-builder:2.7.2-alpine AS Builder

and I saw the bundle command. But with

FROM ledermann/rails-base-builder:2.7.2-alpine AS Builder
FROM ledermann/rails-base-final:2.7.2-alpine

it seem to skip the Builder ONBUILD instructions

Strange. Maybe your docker-rails-base images are out of date?

~  > docker images | grep rails-base
ledermann/rails-base-final                          2.7.2-alpine    0af570e0376d   8 hours ago     64MB
ledermann/rails-base-builder                        2.7.2-alpine    ebe48c72b9ae   8 hours ago     913MB

I suggest to delete your existing base images and try again.

I had buildkit enable!

{
  "experimental": false,
  "features": {
    "buildkit": true
  }
}

It works with

{
  "experimental": false,
  "features": {
    "buildkit": false
  }
}

Thanks for the support

Ok, I need to check out if it's possible to allow BuildKit, too.

Reference: moby/buildkit#816

I was able to get this working by using this workaround: moby/buildkit#816 (comment)

FROM ledermann/rails-base-builder:2.7.2-alpine AS Builder
FROM ledermann/rails-base-final:2.7.2-alpine

# workaround to trigger Builder's ONBUILDs to finish:
COPY --from=Builder /etc/passwd /etc/passwd_builder 

...

@Juice10: Great, thanks! I have added a note to the Readme, so the issue can be closed.