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

feat: Support for buildx #37

Merged

Conversation

ashnamehrotra
Copy link
Contributor

Adds support and documentation for private and local image patching.

  • default approach in action is changed to create a buildx instance
  • the buildx instance needed to be created in entrypoint.sh since creating an instance outside of the container itself does not change anything about the Docker socket that we are mounting
  • if user supplies a buildkit-version input, action will create a buildkit container for connection instead
  • if user supplies a custom-socket input, action will connect to the custom socket which should have containerd img store enabled (Copacetic still outputs the patched img to the "default" docker context rather than the "setup-docker-action" context used to create a socket with containerd img store. I think this is intentional on Copa's side?)
  • adds documentation for these approaches assuming Copacetic v0.6.1 will be released after this

default buildx test run
buildkit container test run
custom socket test run

Fixes #32 #16

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
.github/workflows/build.yaml Outdated Show resolved Hide resolved
action.yaml Outdated Show resolved Hide resolved
Signed-off-by: ashnamehrotra <[email protected]>
Signed-off-by: ashnamehrotra <[email protected]>
Signed-off-by: ashnamehrotra <[email protected]>
Signed-off-by: ashnamehrotra <[email protected]>
Signed-off-by: ashnamehrotra <[email protected]>
uses: crazy-max/ghaction-setup-docker@v3
with:
daemon-config: |
{
Copy link
Member

Choose a reason for hiding this comment

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

nit: indention is off in this json

copa-action 'docker.io/library/nginx:1.21.6' 'nginx.1.21.6.json' '1.21.6-patched' '10m' 'buildx' 'openvex' 'output.json'
bats --print-output-on-failure ./test/test.bats

- name: Bats Test - Buildkit Container
Copy link
Member

Choose a reason for hiding this comment

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

are these going to run sequentially? if so, can we execute in parallel using a matrix

@sozercan
Copy link
Member

@ashnamehrotra looks like build e2e failed with a timeout https://github.com/project-copacetic/copa-action/actions/runs/7878674392/job/21497411542?pr=37 do we need to increase the timeout

@ashnamehrotra
Copy link
Contributor Author

@ashnamehrotra looks like build e2e failed with a timeout https://github.com/project-copacetic/copa-action/actions/runs/7878674392/job/21497411542?pr=37 do we need to increase the timeout

Looking into this, I tested with 20min timeout and its still failing, there might be something else wrong. I also re-ran a test that was originally passing which is failing now.

@sozercan
Copy link
Member

sozercan commented Feb 13, 2024

just fyi if you are passing timeout in the action, I don't think this'll be available in action yet (in non-test) since we didn't cut a release

Signed-off-by: ashnamehrotra <[email protected]>
Signed-off-by: ashnamehrotra <[email protected]>
Signed-off-by: ashnamehrotra <[email protected]>
@ashnamehrotra
Copy link
Contributor Author

just fyi if you are passing timeout in the action, I don't think this'll be available in action yet (in non-test) since we didn't cut a release

The timeout flag should be available in copa-action in v1.1.0 release. Also looks like the timeout error was specific to the nginx image in the build test, created an issue here: project-copacetic/copacetic#504 and changed the test to use the OPA image for now.

Final issue to resolve is for custom-socket approach, trivy is unable to find the patched image in the bats test since it was created in a different context, even when switched to the new context.

Signed-off-by: ashnamehrotra <[email protected]>
Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

Thank you! added a few minor comments, otherwise LGTM

run: |
trivy image --vuln-type os --ignore-unfixed -f json -o /tmp/nginx.1.21.6.json docker.io/library/nginx:1.21.6
trivy image --vuln-type os --ignore-unfixed -f json -o /tmp/opa.0.46.0.json docker.io/openpolicyagent/opa:0.46.0
Copy link
Member

Choose a reason for hiding this comment

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

this is fine for now, but we'll need to add a trivy ignore list like copa in the future as there's no way to avoid false positives

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created issue to add that: #38

docker images
copa-action 'docker.io/openpolicyagent/opa:0.46.0' 'opa.0.46.0.json' '0.46.0-patched' '10m' "${{ matrix.test-type }}" 'openvex' 'output.json'

docker -c "$CONTEXT" save -o patched.tar openpolicyagent/opa:0.46.0-patched
Copy link
Member

@sozercan sozercan Feb 16, 2024

Choose a reason for hiding this comment

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

why are we saving to a tarball? because trivy can't scan it? if so, can you add a note

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I did some research but I couldn't find a way to get trivy access without saving to tarball. Added a note for that!

README.md Outdated
| `custom-socket` | String | False | | Custom Docker socket address (available with copa-action v0.6.1 and later) |

> [!NOTE]
> Copacetic released version's features do not align with Copa Action versions.
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit confusing. Are we saying copa may have features that action might not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant to say that if a feature was released in Copa version v0.6.0 (like patching local images), it wont necessarily be supported in Copa-Action version v0.6.0. In this case it will supported starting with Copa-Action v0.6.1. I changed the wording a bit to try to make it more clear.

Signed-off-by: ashnamehrotra <[email protected]>
Signed-off-by: ashnamehrotra <[email protected]>
@ashnamehrotra ashnamehrotra merged commit fa30cbf into project-copacetic:main Feb 20, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

support for buildx builders and containerd image store
2 participants