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

⭐ Dockerfile support #3806

Merged
merged 5 commits into from
Apr 22, 2024
Merged

⭐ Dockerfile support #3806

merged 5 commits into from
Apr 22, 2024

Conversation

arlimus
Copy link
Member

@arlimus arlimus commented Apr 22, 2024

Start to add Dockerfile support. You can now:

cnquery ACTION docker file DOCKERFILE

Example:

cnquery shell docker file Dockerfile

cnquery scan docker file Dockerfile.dev

This exposes new keyworeds, which are attached to docker.file.

1. Commands

All instructions are accessible in a structured way. Please note that a Dockerfile may have multiple stages.

> docker.file.stages{*}
docker.file.stages: [
  0: {
    entrypoint: docker.file.run script="cnquery"
    add: []
    run: [
      0: docker.file.run script="apk update &&    apk add ca-certificates wget tar &&    rm -rf /var/cache/apk/*"
    ]
    from: docker.file.from name="root" image="alpine" tag="3.19"
    env: {}
    copy: [
      0: docker.file.addcopy src=[
        0: "cnquery"
      ] dst="/usr/local/bin"
    ]
    cmd: docker.file.run script="help"
  }
  1: {
    entrypoint: null
    add: []
...

2. Instructions

An alternative is to access low-level instructions. These are great if you just want to interact with all the instructions without thinking about their context.

> docker.file.instructions
docker.file.instructions: [
  0: {
    original: "FROM alpine:3.19 AS root"
  }
  1: {
    original: "RUN apk update &&    apk add ca-certificates wget tar &&    rm -rf /var/cache/apk/*"
  }
...

3. File access

Finally, a docker.file has the regular file resource embedded. This means you can use anything that is accessible in file (given that #3805 merges before this).

> docker.file.path
docker.file.file.path: "Dockerfile"

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Apr 22, 2024

Test Results

2 980 tests  +3   2 979 ✅ +3   1m 35s ⏱️ -10s
  329 suites +1       1 💤 ±0 
   23 files   ±0       0 ❌ ±0 

Results for commit 7c4cfcd. ± Comparison against base commit a98c247.

♻️ This comment has been updated with latest results.

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woot! Nice addtion.

utils/urlx/urlx.go Show resolved Hide resolved

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Signed-off-by: Dominik Richter <[email protected]>
Signed-off-by: Dominik Richter <[email protected]>
This is hedging against downstream changes which might make these objects entirely separate. There is a small difference and we might decide to expose it in the future for these two resource types.

Signed-off-by: Dominik Richter <[email protected]>
@arlimus arlimus merged commit 1f017f6 into main Apr 22, 2024
15 checks passed
@arlimus arlimus deleted the dom/dockerfile branch April 22, 2024 22:00
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants