tuenti / secrets-manager

A daemon to sync Vault secrets to Kubernetes secrets
Apache License 2.0
171 stars 26 forks source link

Unable to build 1.0.1 #37

Closed rvojcik closed 4 years ago

rvojcik commented 4 years ago

Hi guys,

Today I tried to build v1.0.1 but I get this error. I'm not very familiar with Go so sorry for poor debug from me.

Step 8/16 : COPY controllers/ controllers/
 ---> 273c7d4ba1db
Step 9/16 : COPY backend/ backend/
 ---> f7408c3189eb
Step 10/16 : COPY errors/ errors/
 ---> 1eb5effb65c1
Step 11/16 : ARG SECRETS_MANAGER_VERSION
 ---> Running in 7095e5eb74c8
Removing intermediate container 7095e5eb74c8
 ---> d63f784cf605
Step 12/16 : RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "-X main.version=${SECRETS_MANAGER_VERSION}" -a -o secrets-manager main.go
 ---> Running in 4e7431fdf222
# github.com/tuenti/secrets-manager/api/v1alpha1
api/v1alpha1/secretdefinition_types.go:68:25: cannot use &SecretDefinition literal (type *SecretDefinition) as type runtime.Object in argument to SchemeBuilder.Register:
    *SecretDefinition does not implement runtime.Object (missing DeepCopyObject method)
api/v1alpha1/secretdefinition_types.go:68:46: cannot use &SecretDefinitionList literal (type *SecretDefinitionList) as type runtime.Object in argument to SchemeBuilder.Register:
    *SecretDefinitionList does not implement runtime.Object (missing DeepCopyObject method)
The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "-X main.version=${SECRETS_MANAGER_VERSION}" -a -o secrets-manager main.go' returned a non-zero code: 2
fcgravalos commented 4 years ago

Hi @rvojcik !!

This is how I build the docker image:

GO111MODULE=on DOCKER_REGISTRY="<my-docker-registry/repo>" make docker-build

How are you building it?

Thanks!

rvojcik commented 4 years ago

Hi, sorry for delay. I just run docker build so it builds inside docker container as it's specified in Dockerfile. It uses go 1.12 image

# Build the manager binary
FROM golang:1.12.5 as builder

and build

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "-X main.version=${SECRETS_MANAGER_VERSION}" -a -o secrets-manager main.go

I noticed it when it failed build on hub.docker.com.

fcgravalos commented 4 years ago

I think you might be missing the build args. Can you just run make as I showed you above?

fcgravalos commented 4 years ago

@rvojcik did you have a chance to test it?

rvojcik commented 4 years ago

Hi, sorry was too busy. I didn't tried it so far. I tried just docker build . which use Dockerfile inside git repo to build it in docker containers. It was the main problem for me because I didn't build docker image myself and I let the registry service to build it for me when something changed.

rvojcik commented 4 years ago

Ok I found the problem, I have to set env variable SECRETS_MANAGER_VERSION. So I have to somehow set it to the build process

rvojcik commented 4 years ago

Ok another update. Somehow when I tried to build it like you say, it's worked, and from there it's it worked every time even when run docker buil . but.. when I clone clean repository and run docker build above it, it fails with that error.

This file is missing api/v1alpha1/zz_generated.deepcopy.go when I run docker build on cleanly cloned repo

avenging commented 4 years ago

Add these 2 lines before the build in the Dockerfile and it will build straight from the dockerfile (with the build argument set for version) RUN go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0-beta.2 RUN /go/bin/controller-gen object:headerFile=./hack/boilerplate.go.txt paths=./api/... Docker build: docker build --build-arg SECRETS_MANAGER_VERSION=1.0.1 .

rvojcik commented 4 years ago

Thanks, it works now. I have to add COPY hack/ hack/