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

Building the image with Docker Engine 27+ gives some warnings #686

Closed
kurokobo opened this issue Jun 23, 2024 · 0 comments · Fixed by #687
Closed

Building the image with Docker Engine 27+ gives some warnings #686

kurokobo opened this issue Jun 23, 2024 · 0 comments · Fixed by #687
Labels
needs_triage New item that needs to be triaged

Comments

@kurokobo
Copy link
Contributor

kurokobo commented Jun 23, 2024

Description

Docker Engine 27+ uses new BuildKit 0.14+ to build images by default, and BuildKit 0.14.x has new feature that validates if syntax in Dockerfile meet best practices.

Default Dockerfile frontend has been updated to v1.8.0
https://github.com/moby/buildkit/releases/tag/v0.14.0

Many new validation rules have been added to verify that your Dockerfile is using best practices. These rules are validated during build and new "lint" subrequest can be used to only trigger validation without completing the whole build.
https://github.com/moby/buildkit/releases/tag/dockerfile/1.8.0

Refer to the Build checks section of Docker Docs to see which rules are validated: https://docs.docker.com/reference/build-checks/

The problem is, the Dockerfile that generated by current ansible-builder does not follow this rule; FROM is uppercased but as is lowercased: https://docs.docker.com/reference/build-checks/from-as-casing/

# Base build stage
FROM $EE_BASE_IMAGE as base
...
# Galaxy build stage
FROM base as galaxy
...
# Builder build stage
FROM base as builder
...
# Final build stage
FROM base as final

This will result in a successful build, but some warnings to be displayed:

$ ansible-builder build --tag registry.example.com/ansible/ee:2.17-minimal --container-runtime docker --verbosity 3
Ansible Builder is generating your execution environment build context.
...
Ansible Builder is building your execution environment image. Tags: registry.example.com/ansible/ee:2.17-minimal
Running command:
  docker build -f context/Dockerfile -t registry.example.com/ansible/ee:2.17-minimal context
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2.96kB done
#1 WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 11) ✅
#1 WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 31) ✅
#1 WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 50) ✅
#1 WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 70) ✅
...

#31 [final 9/9] RUN rm -rf /output
#31 DONE 0.1s

#32 exporting to image
#32 exporting layers
#32 exporting layers 0.6s done
#32 writing image sha256:73227f703dbf35eb822caa325f0db8593fb10719bbb64d21615ea7ddd50df04e done
#32 naming to registry.example.com/ansible/ee:2.17-minimal done
#32 DONE 0.6s

 4 warnings found (use --debug to expand): ✅
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 11) ✅
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 31) ✅
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 50) ✅
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 70) ✅

Complete! The build context can be found at: /home/********/builder/context

Environment

$ docker version
Client: Docker Engine - Community
 Version:           27.0.1-rc.1
 API version:       1.46
 Go version:        go1.21.11
 Git commit:        0d415ad
 Built:             Thu Jun 20 15:59:18 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.0.1-rc.1
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.11
  Git commit:       018d93d
  Built:            Thu Jun 20 15:57:34 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.18
  GitCommit:        ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
 runc:
  Version:          1.7.18
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

$ docker buildx ls
NAME/NODE     DRIVER/ENDPOINT   STATUS    BUILDKIT   PLATFORMS
default*      docker                                 
 \_ default    \_ default       running   v0.14.1    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386

Steps to reproduce

  1. Install docker engine 27+

  2. Build EE with following yaml with --container-runtime docker

    ---
    version: 3
    images:
      base_image:
        name: quay.io/centos/centos:stream9-minimal
    
    options:
      package_manager_path: /usr/bin/microdnf
    
    dependencies:
      python_interpreter:
        package_system: python3.12
        python_path: /usr/bin/python3.12
      ansible_core:
        package_pip: ansible-core~=2.17
      ansible_runner:
        package_pip: ansible-runner~=2.4
      galaxy:
        collections:
          - name: community.general
            version: 9.1.0
            source: https://galaxy.ansible.com
    
    additional_build_steps:
      append_base:
        - RUN alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 0
@github-actions github-actions bot added the needs_triage New item that needs to be triaged label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_triage New item that needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant