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

Terrascan 1.3.0 fails to build on alpine #506

Closed
ifosch opened this issue Jan 21, 2021 · 4 comments
Closed

Terrascan 1.3.0 fails to build on alpine #506

ifosch opened this issue Jan 21, 2021 · 4 comments
Assignees
Labels

Comments

@ifosch
Copy link

ifosch commented Jan 21, 2021

  • terrascan version: 1.3.0
  • Operating System: alpine

Description

I have a Dockerfile for terrascan which is failing to build version 1.3.0.
There is some dependency problem happening when running go get.
With version 1.2.0 it was working fine.

What I Did

The Dockerfile is like the following:

FROM golang:alpine AS build-env

RUN apk add --update git

RUN CGO_ENABLED=0 GO111MODULE=on go get github.com/accurics/terrascan/cmd/terrascan

FROM scratch

COPY --from=build-env /go/bin/terrascan /usr/bin/terrascan
COPY --from=build-env /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENTRYPOINT [ "/usr/bin/terrascan" ]

Then the command I'm using to build it is

docker build -t terrascan:1.3.0 terrascan/

The output fails with the following error:

pkg/mod/k8s.io/client-go@v10.0.0+incompatible/discovery/cached_discovery.go:28:2: module github.com/googleapis/gnostic@latest found (v0.5.3), but does not contain package github.com/googleapis/gnostic/OpenAPIv2
pkg/mod/k8s.io/kube-openapi@v0.0.0-20200805222855-6aeccd4b50c6/pkg/util/proto/document.go:24:2: case-insensitive import collision: "github.com/googleapis/gnostic/openapiv2" and "github.com/googleapis/gnostic/OpenAPIv2"
pkg/mod/k8s.io/client-go@v10.0.0+incompatible/kubernetes/scheme/register.go:22:2: module k8s.io/api@latest found (v0.20.2), but does not contain package k8s.io/api/admissionregistration/v1alpha1
pkg/mod/k8s.io/client-go@v10.0.0+incompatible/kubernetes/scheme/register.go:27:2: module k8s.io/api@latest found (v0.20.2), but does not contain package k8s.io/api/auditregistration/v1alpha1
@amirbenv amirbenv added the bug label Jan 21, 2021
@amirbenv
Copy link
Contributor

Thanks for the report! Looking into it

@jlk
Copy link
Contributor

jlk commented Jan 21, 2021

hey @ifosch - I'm digging into see what's up here. I can reproduce with your Dockerfile, but using ours (build/Dockerfile) it works fine...

The issues seem to be with 3rd party code - client-go and kube-openapi. Will keep poking to see what's up...

@jlk jlk self-assigned this Jan 21, 2021
@williepaul
Copy link
Contributor

williepaul commented Jan 22, 2021

There are some known issues with some of the indirect dependencies of the libraries we use. (see kubernetes/client-go#741 for more info). In the meantime, a possible workaround would be to clone and build instead of using go get to do it. Here's a working example based on your dockerfile above:

FROM golang:alpine AS build-env

RUN apk add --update git

RUN git clone https://github.com/accurics/terrascan && cd terrascan \
  && CGO_ENABLED=0 GO111MODULE=on go build -o /go/bin/terrascan cmd/terrascan/main.go

FROM scratch

COPY --from=build-env /go/bin/terrascan /usr/bin/terrascan
COPY --from=build-env /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENTRYPOINT [ "/usr/bin/terrascan" ]

@ifosch
Copy link
Author

ifosch commented Jan 22, 2021

Great, I've tested this and this way i can build terrascan 1.3.0 ok. Thank you so much @williepaul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants