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

Alpine Docker Image does not work in Gitlab CI #106

Closed
pSub opened this issue Apr 13, 2022 · 6 comments
Closed

Alpine Docker Image does not work in Gitlab CI #106

pSub opened this issue Apr 13, 2022 · 6 comments

Comments

@pSub
Copy link

pSub commented Apr 13, 2022

I am unable to integrate kubeconform into our Gitlab CI pipeline using the Alpine docker image. The relevant part of my Gitlab CI configuration is

lint-kubeconform:
  stage: validate
  image: ghcr.io/yannh/kubeconform:latest-alpine
  script:
    - kubeconform

The gitlab-runner fails to find a sh:

Runtime platform                                    arch=amd64 os=linux pid=40134 revision=f188edd7 version=14.9.1
Running with gitlab-runner 14.9.1 (f188edd7)
Preparing the "docker" executor
Using Docker executor with image ghcr.io/yannh/kubeconform:latest-alpine ...
Pulling docker image ghcr.io/yannh/kubeconform:latest-alpine ...
Using docker image sha256:48581c23a24fb25e270c6a6900b5fe9c4bd0095b7fe8779cdb45b94217686e6d for ghcr.io/yannh/kubeconform:latest-alpine with digest ghcr.io/yannh/kubeconform@sha256:a46a016956f6f91de40e1a635c1c7f75748720db592540b28a1c80f08c8d5991 ...
Preparing environment
Running on runner--project-0-concurrent-0 via LX-02014465...
Getting source from Git repository
Fetching changes...
Initialized empty Git repository in /builds/project-0/.git/
Created fresh repository.
Checking out f1afcbf4 as feature/kubeconform...

Skipping Git submodules setup
Executing "step_script" stage of the job script
Using docker image sha256:48581c23a24fb25e270c6a6900b5fe9c4bd0095b7fe8779cdb45b94217686e6d for ghcr.io/yannh/kubeconform:latest-alpine with digest ghcr.io/yannh/kubeconform@sha256:a46a016956f6f91de40e1a635c1c7f75748720db592540b28a1c80f08c8d5991 ...
sh - failed validation: lstat sh: no such file or directory
-c - failed validation: lstat -c: no such file or directory
ERROR: Job failed: exit code 1

FATAL: exit code 1  

It looks like the error described in #47. Is there something wrong with my configuration or is this a regression?

@balonik
Copy link

balonik commented May 25, 2022

The issue is in ENTRYPOINT ["/kubeconform"] line in Dockerfile which GitLab Runners with Docker executor (the shared ones on GitLab.com) respect and then what's actually being executed is:

kubeconform sh -c anything_you_have_in_script

as you can see this error is actually returned by kubeconform binary

sh - failed validation: lstat sh: no such file or directory
-c - failed validation: lstat -c: no such file or directory

solution is to override entrypoint, you can do it in your .gitlab-ci.yaml file:

image:
  name: ghcr.io/yannh/kubeconform:latest-alpine
  entrypoint: [""]

Note: You won't encounter this issue on GitLab runners with Kubernetes executor, because they ignore ENTRYPOINT entry in container image :P

@pSub
Copy link
Author

pSub commented May 26, 2022

Thank you for this workaround @balonik!

@yannh
Copy link
Owner

yannh commented Jun 19, 2022

What do you think would be the best way for this do you think, just add some documentation? Changing the entrypoint can be weird sometimes with how signals are processed, if Gitlab lets you override the entrypoing Iä d rather do this.

@balonik
Copy link

balonik commented Jul 21, 2022

I think a documentation for this specific use-case is OK.

@pSub
Copy link
Author

pSub commented Jul 24, 2022

I agree with @balonik, adding documentation for this case is enough.

@yannh
Copy link
Owner

yannh commented Oct 16, 2022

Documentation added in #139 I hope it is sufficient! Feel free to send a PR for more details if not 🙇‍♂️

@yannh yannh closed this as completed Oct 16, 2022
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

3 participants