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

Fix docker build issue (error obtaining VCS status) #11

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

christoph-jerolimov
Copy link
Member

I want to build this webterminal-proxy to test the Janus webtermina-plugin but couldn't build it on OpenShift nor my machine when running:

I got this error when running go build -o . or docker build ..

And, I got the same issue when building on an OpenShift cluster:

 => ERROR [builder 3/3] RUN go build -o .                                                                                                              0.4s
------                                                                                                                                                      
 > [builder 3/3] RUN go build -o .:                                                                                                                         
0.202 go: downloading github.com/gorilla/websocket v1.5.0                                                                                                   
0.402 error obtaining VCS status: exit status 128
0.402 	Use -buildvcs=false to disable VCS stamping.
------
Dockerfile:3
--------------------
   1 |     FROM registry.access.redhat.com/ubi9/go-toolset:latest AS builder
   2 |     COPY . .
   3 | >>> RUN go build -o .
   4 |     
   5 |     FROM registry.access.redhat.com/ubi9-micro:latest
--------------------
ERROR: failed to solve: process "/bin/sh -c go build -o ." did not complete successfully: exit code: 1

My go version is: go1.21.5 linux/amd64

The docker image uses currently: go version go1.20.10 linux/amd64

I added -buildvcs=false to solve that bug. See golang/go#49004

To be honest, I'm unsure why this is now required. Wdyt?

@mimotej
Copy link

mimotej commented Dec 21, 2023

Not sure why is it failing locally, when I try it on fresh clone of the repo with same version of go it works. The issue with the docker/podman is present tho and from what I saw it might be also fixable by adding .dockerignore where we specify .git (I think it is not necessary there anyway is it?). Once .git is ignored building image should work. I guess both options should be fine so I will let you decide. :)

@christoph-jerolimov
Copy link
Member Author

I tried the .dockerignore solution first, but it didn't help me. Looks like the docker build cache was to optimistic for the COPY . . step.

With docker build --progress=plain --no-cache . I can confirm as well that it's working fine. So we can go just with that additional file and I will revert the change in the Dockerfile.

Thanks for your fast review. :)

@christoph-jerolimov christoph-jerolimov changed the title Fix build issue (error obtaining VCS status) Fix docker build issue (error obtaining VCS status) Dec 21, 2023
@christoph-jerolimov
Copy link
Member Author

Hey @mimotej, also, if it's just a simple .dockerignore file, it is still required for me to build the container successfully:

# on main branch:

➜  ~/git/janus-idp/webterminal-proxy git:(main) docker build --progress=plain --no-cache .
#0 building with "default" instance using docker driver

#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 335B done
#2 DONE 0.0s

#3 [internal] load metadata for registry.access.redhat.com/ubi9/go-toolset:latest
#3 DONE 0.2s

#4 [internal] load metadata for registry.access.redhat.com/ubi9-micro:latest
#4 DONE 0.2s

#5 [builder 1/3] FROM registry.access.redhat.com/ubi9/go-toolset:latest@sha256:077f292da8bea9ce7f729489cdbd217dd268ce300f3e216cb1fffb38de7daeb9
#5 CACHED

#6 [stage-1 1/2] FROM registry.access.redhat.com/ubi9-micro:latest@sha256:14a2cd49b11eb39586f5abdefc63739f47cd5b8099e0d6946d7ee24812e7e746
#6 CACHED

#7 [internal] load build context
#7 transferring context: 28.16kB 0.0s done
#7 DONE 0.0s

#8 [builder 2/3] COPY . .
#8 DONE 0.1s

#9 [builder 3/3] RUN go build -o .
#9 0.228 go: downloading github.com/gorilla/websocket v1.5.0
#9 0.464 error obtaining VCS status: exit status 128
#9 0.464 	Use -buildvcs=false to disable VCS stamping.
#9 ERROR: process "/bin/sh -c go build -o ." did not complete successfully: exit code: 1
------
 > [builder 3/3] RUN go build -o .:
0.228 go: downloading github.com/gorilla/websocket v1.5.0
0.464 error obtaining VCS status: exit status 128
0.464 	Use -buildvcs=false to disable VCS stamping.
------
Dockerfile:3
--------------------
   1 |     FROM registry.access.redhat.com/ubi9/go-toolset:latest AS builder
   2 |     COPY . .
   3 | >>> RUN go build -o .
   4 |     
   5 |     FROM registry.access.redhat.com/ubi9-micro:latest
--------------------
ERROR: failed to solve: process "/bin/sh -c go build -o ." did not complete successfully: exit code: 1

vs

➜  ~/git/janus-idp/webterminal-proxy git:(main) git checkout fix-obtaining-vcs-issue 
Switched to branch 'fix-obtaining-vcs-issue'

➜  ~/git/janus-idp/webterminal-proxy git:(fix-obtaining-vcs-issue) docker build --progress=plain --no-cache .
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 335B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 122B done
#2 DONE 0.0s

#3 [internal] load metadata for registry.access.redhat.com/ubi9/go-toolset:latest
#3 DONE 0.2s

#4 [internal] load metadata for registry.access.redhat.com/ubi9-micro:latest
#4 DONE 0.2s

#5 [builder 1/3] FROM registry.access.redhat.com/ubi9/go-toolset:latest@sha256:077f292da8bea9ce7f729489cdbd217dd268ce300f3e216cb1fffb38de7daeb9
#5 CACHED

#6 [stage-1 1/2] FROM registry.access.redhat.com/ubi9-micro:latest@sha256:14a2cd49b11eb39586f5abdefc63739f47cd5b8099e0d6946d7ee24812e7e746
#6 CACHED

#7 [internal] load build context
#7 transferring context: 896B done
#7 DONE 0.0s

#8 [builder 2/3] COPY . .
#8 DONE 0.0s

#9 [builder 3/3] RUN go build -o .
#9 0.210 go: downloading github.com/gorilla/websocket v1.5.0
#9 DONE 29.3s

#10 [stage-1 2/2] COPY --from=builder  /opt/app-root/src/webterminal-proxy /
#10 DONE 0.1s

#11 exporting to image
#11 exporting layers 0.1s done
#11 writing image sha256:ba133ccd81ad17a925188aa8664555d840d558c1d45f9417bcc6431fdb88f69e done
#11 DONE 0.1s

@christoph-jerolimov
Copy link
Member Author

ping @mimotej 😄

@mimotej
Copy link

mimotej commented Jan 16, 2024

Sorry for late review on this, I was off for a while. I think this solution sounds good so LGTM from my side. 🚢

@christoph-jerolimov
Copy link
Member Author

@tumido can you approve/merge this?

Copy link
Member

@tumido tumido left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Copy link

openshift-ci bot commented Feb 20, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mimotej, tumido

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tumido tumido merged commit e79a1d4 into janus-idp:main Feb 20, 2024
5 of 6 checks passed
@christoph-jerolimov christoph-jerolimov deleted the fix-obtaining-vcs-issue branch February 20, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants