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

Update Dockerfile and fix Docker build failed #299

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

nekoteoj
Copy link
Contributor

@nekoteoj nekoteoj commented Jan 2, 2024

Problem:
The current Dockerfile doesn't work when building the image. Consequently, the Docker compose file also doesn't work. This problem is caused by following issues.

  1. The latest go version (1.21) can't compile the source file usb/lowlevel/libusb/libusb.go with these error messages.
usb/lowlevel/libusb/libusb.go:405:10: cannot define new methods on non-local type *C.struct_libusb_endpoint_descriptor
usb/lowlevel/libusb/libusb.go:455:10: cannot define new methods on non-local type *C.struct_libusb_interface_descriptor
usb/lowlevel/libusb/libusb.go:510:10: cannot define new methods on non-local type *C.struct_libusb_interface
usb/lowlevel/libusb/libusb.go:557:10: cannot define new methods on non-local type *C.struct_libusb_config_descriptor
usb/lowlevel/libusb/libusb.go:615:10: cannot define new methods on non-local type *C.struct_libusb_ss_endpoint_companion_descriptor
usb/lowlevel/libusb/libusb.go:639:10: cannot define new methods on non-local type *C.struct_libusb_bos_dev_capability_descriptor
usb/lowlevel/libusb/libusb.go:662:10: cannot define new methods on non-local type *C.struct_libusb_bos_descriptor
usb/lowlevel/libusb/libusb.go:694:10: cannot define new methods on non-local type *C.struct_libusb_usb_2_0_extension_descriptor
usb/lowlevel/libusb/libusb.go:721:10: cannot define new methods on non-local type *C.struct_libusb_ss_usb_device_capability_descriptor
usb/lowlevel/libusb/libusb.go:749:10: cannot define new methods on non-local type *C.struct_libusb_container_id_descriptor
usb/lowlevel/libusb/libusb.go:796:10: cannot define new methods on non-local type *C.struct_libusb_device_descriptor
usb/lowlevel/libusb/libusb.go:866:10: cannot define new methods on non-local type *C.struct_libusb_transfer
usb/lowlevel/libusb/libusb.go:895:10: cannot define new methods on non-local type *C.struct_libusb_version
  1. The current build process used go get outside of the go module directory. However, go get is no longer supported outside a module.

Solution:

  1. Fix the golang image version to 1.18 to ensure that the image can be successfully built. This is the same version that is used in the repository's GitHub workflow.
  2. Instead of using go get to get the source code in the image, the whole repository is copied to the image. Previously, only the run script was copied to the image.

@sime
Copy link
Member

sime commented Jan 3, 2024

Hey @nekoteoj thanks for the contribution.

Does this PR resolve #297 ?

@nekoteoj
Copy link
Contributor Author

nekoteoj commented Jan 3, 2024

Hey! Thanks for reviewing!

I think the error when building the docker image is the same as #297 due to golang 1.21. This PR doesn't resolve #297 since I only edited the Dockerfile. This PR changed the golang image version to 1.18 so the docker image could still be built (I think this is more like a workaround for building the image while we still cannot build the repo using golang 1.21). I also edit the build script in the Dockerfile since go get cannot run outside of go module directory now.

Also, the compiled trezord-go executable from the docker image run fine on my host os (Void Linux). So I think this can be used as an alternative build method for system with golang version >= 1.21 too.

Copy link
Member

@vdovhanych vdovhanych left a comment

Choose a reason for hiding this comment

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

Looking good, older golang version is because of the build failing on 1.21?

@nekoteoj
Copy link
Contributor Author

nekoteoj commented Jan 3, 2024

Yes, and the other reason is that I saw the github workflow used go 1.18 in check-go-validation.yml.

@tsusanka tsusanka merged commit b3adc1f into trezor:master Jan 4, 2024
1 of 2 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.

4 participants